I was wondering the following thing. How to get the count of the matching fields?
Like if you have a query with boosting of some kind o following query.
If you do not care about the the BM25 score, and just want a score based on the number of matching fields, you can switch to the boolean similarity. This will calculate a score of 0 or 1, depending on whether a field is a match or not.
Alright, so you want to have both the original BM25 scores using the boosts, as well as have Elasticsearch return the number of matching fields? I can think of one way of doing that, which requires your query to be written more verbosely.
First, rewrite your multi_match query to a dis_max query. The dis_max query is a more verbose way of writing a multi_match query of type best_fields. Your query can be rewritten into:
Now, you can use named queries to let Elasticsearch tell you which of the sub queries actually matched each document. Using this feature, the dis_max query can be written as:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.