How do we do a contains string search in elasticsearch in more than 1 field efficiently e.g text "denis tomas" should be searchable by query "tom". I stumbled upon query_string query but usage of wildcards make it inefficient. Also, ngram tokenizer doesn't lead to a true contains search unless using with multi-match with and operator which again increases the number of clauses. Is there any (optimizations over the above two)/other efficient way for contains search?
Have you looked at using a wildcard field together with a wildcard query?
I was going through its documentation. However at the bottom it says the wildcard query is categorized as expensive? Wildcard query | Elasticsearch Guide [8.12] | Elastic.
It is if you run it against a field that is not mapped as wildcard. I can not think of any other way to do what you want in an efficient way.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.