How to use minimum_should_match for prefix search?

I want to make a search-as-you-type search service (with tokenization, analyzer etc.) and to use minimum_should_match in it, i.e. to show pages with three of four typed tokens but not with two of four.

What is the best way to do it?

One that I see is to add * to the text typed (to make it work as a prefix search) and to wrap it into simple_query_string or query_string, but this approach has obvious disadvantages, for example these types of queries take into account all wildcard symbols (- " etc.) which is often inconvenient.

Have you looked into using an analyzer with an edge ngram filter? You could set min_gram to 3 to avoid matching on short strings.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.