ElasticSearch multi_match query across multiple fields with Fuzziness

How to add ambiguity to a multi_match request? Therefore, if someone searches for “basketball,” he will still find “baseball” articles. Currently my query looks like this:

POST /newspaper/articles/_search { "query": { "function_score": { "query": { "multi_match": { "query": "baseball", "type": "phrase", "fields": [ "subject^3", "section^2.5", "article^2", "tags^1.5", "notes^1" ] } } } } } 

One option that I have been considering is to do something like this, I just don't know if this is the best option. It is important to maintain sorting based on the score:

  "query" : { "query_string" : { "query" : "subject:basball^3 section:basball^2.5 article:basball^2", "fuzzy_prefix_length" : 1 } } 

Suggestions?

+7
elasticsearch fuzzy-search
source share
1 answer

To add fuzziness to multiquery, you need to add the fuzziness property, as described here:

 { "query": { "function_score": { "query": { "multi_match": { "query": "baseball", "type": "phrase", "fields": [ "subject^3", "section^2.5", "article^2", "tags^1.5", "notes^1" ], "fuzziness" : "AUTO", "prefix_length" : 2 } } } } } 

Note that prefix_length is explained in the document as:

The number of leading characters that will not be "fuzzified". This helps to reduce the number of terms that need to be learned. The default is 0.

To check for possible blur values, visit the ES docs .

+19
source share

All Articles