One of the nice features of ElasticSearch is the support for 'stemming’. Stemming brings a word back to its root. For example a search on skis or skiing will both match results with ski. Typically you still want to support search operations on the original word by applying a multi-field approach where you index both the stemmed values and the original value:
But now you need to know if your user is searching for an exact match(e.g. a search for ski should only return results where the original value was ski) or stemmed results. Fortunately, the query_string
and simple_query_string
queries have a feature that solve this exact problem: quote_field_suffix
. This tell Elasticsearch that the words that appear in between quotes are to be redirected to a different field, see below:
Now if ski
is in-between quotes, it issearched on the productName.raw
field due to the quote_field_suffix
parameter.