0
Answered

Search by Phrase - Content

Brian R 5 months ago updated 3 months ago 2

We have Elasticsearch configured with FileRun using Elastic Cloud.  Everything is working perfectly, but I'm hoping to limit search results, instead of expanding them, when a user types multiple words or a phrase. For example:

A search for blue hats would bring back all documents containing the word "blue" and all documents containing "hats".  We really need it to just bring back all documents containing "blue hats".

Is there a way to achieve this?

Thanks,

Brian

Answer

Answer
Answered

You can search for documents that contain both terms like this "blue AND hats". For more details on this syntax and more advanced searches, please see this page: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-wildcard

Answer
Answered

You can search for documents that contain both terms like this "blue AND hats". For more details on this syntax and more advanced searches, please see this page: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-wildcard

After entering "blue AND" (while entering " hats") the following error appears: "Failed to parse query [blue AND ]".

It works without errors if the user types: "blue hats" and then finally inserts "AND".

I would suggest an "AND / OR" switch option near the text field for content search. So the operators could be inserted automatically without any error before the search string is forwarded to elasticsearch.

Regards Andreas