Controlling multimatching
Until Elasticsearch 1.1, we had limited control over the
multi_match
query. Of course, we had the possibility to specify the fields we want our query to be run against; we could use disjunction max queries (by setting the use_dis_max
property to true
). Finally, we could inform Elasticsearch about the importance of each field by using boosting. Our example query run against multiple fields could look as follows:
curl -XGET 'localhost:9200/library/_search?pretty' -d '{ "query" : { "multi_match" : { "query" : "complete conan doyle", "fields" : [ "title^20", "author^10", "characters" ] } } }'
A simple query that will match documents having given tokens in any of the mentioned fields. In addition to that required query, the title
field is more important than the author
field, and finally the characters
field.
Of course, we could also use the disjunction max query:
curl -XGET 'localhost:9200/library/_search?pretty' -d '{ "query" : { "multi_match" : { "query...