Skip to content
← Back to activity

Solution skill

How to perform a keyword search in marqo

Version 4Sign in to save

Complete solution

Walks through perform a keyword search in marqo, step by step. Use it when you need to do exactly this. Not a troubleshooting guide, so skip it if you are here because of an error.

TL;DR

All you have to do is pass another keyword argument search\method="LEXICAL" to the.search() method here is how your code should look like: `` result = mq.index("my-index").search(q='keyword', search\method="LEXICAL") results = mq.index("my-index").search( q="keyword" ) 2. this is how the output look like: ` {'hits': [{'Description': "document1description", 'Title': 'document1title', 'highlights': bestmatch, 'id': 'd65454db-680c-4f77-8c82-f9aaea66efa1', 'score': 0.5562359},...

When to use

Use this skill when you run into "How to perform a keyword search in marqo".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Steps

  1. All you have to do is pass another keyword argument search_method="LEXICAL" to the .search() method here is how your code should look like:

``` results = mq.index("my-index").search( q="keyword" ) ```

2. this is how the output look like: ``` {'hits': [{'Description': "document_1_description", 'Title': 'document_1_title', '_highlights': best_match, '_id': 'd65454db-680c-4f77-8c82-f9aaea66efa1', '_score': 0.5562359},...

Evidence

Source: Stack Overflow #74405390 (accepted answer, 3 votes): i have been searching through documents in marqo by passing a query as an argument to the .search() method but this returns a list of documents from best to least match. i will like to pass a keyword from the document and i should only get the documents that have those keyword this is how i currently search: `` results = mq.index("my-index").search( q="keyword" ) this is how the output look like: `` {'hits': [{'Description': "document1description", 'Title': 'document1title', 'highlights': bestmatch, 'id': 'd65454db-680c-4f77-8c82-f9aaea66efa1', 'score': 0.5562359},...

Verified resolution: All you have to do is pass another keyword argument search_method="LEXICAL" to the .search() method here is how your code should look like: `` result = mq.index("my-index").search(q='keyword', search_method="LEXICAL")

Source URL: https://stackoverflow.com/questions/74405390/how-to-perform-a-keyword-search-in-marqo

By @issueatlas · Version 4 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_e3Aos7jVH_QhKRdhkB00vw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">How to perform a keyword search in marqo <span>— Vectle</span></a>