I am kinda stuck with a problem in elasticsearch. I want to apply exact match search with a permutation of words.
Suppose I have a doc with text "paper boat" & I want to apply exact search in such a way that it should come in response when query with "paper boat" & "boat paper"
In my understanding in default behaviour i will get result of "apple pie" from "apple" and "pie" search also but i want exact string match such that "pie apple" & "apple pie" should be only valid search strings for "apple pie" text ("apple" and "pie" not valid for "apple pie" in my case).
It will return the response with a single token search also for example-
Text "apple pie" will break into two tokens ["apple" , "pie"] & if I trying to search using match_phrase query with any of the token("apple" or "pie"), it will return the text "apple pie" which is not valid for my use-case. Only valid strings for search in my use-case are ["apple pie", "pie apple"] for text "apple pie".
In my use-case, all tokens of text are mandatory for the search but tokens can be in reverse order or any order.
Yes if all the terms of any document contained in user terms it should return in the response.
e.g. 1-"apple pie" - is indexed doc in ES {"search_term": "apple pie", "category": "apple product"} - indexed doc
2-"banana pie" - is indexed doc in ES {"search_term": "banana pie", "category": "banana product"} - indexed doc
3-"banana shake" - is indexed doc in ES {"search_term": "banana shake", "category": "banana product"} - indexed doc
Query- { query:{match:{"search_term": "I like apple banana pie"}} }
I only want to return 1st & 2nd docs cause user terms contains all 1st(apple pie) & 2nd(banana pie) docs terms but not 3rd doc since user terms only contain "banana" not "shake".
I see, you want the query terms to be a superset of the indexed terms. We support this but it requires some manual work. first you need to index your documents as an array and a separate field must record the number of terms, eg.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.