There is one more exact way to find out which field is matched in the query.
Because highlighting is the process of highlighting after publication, it is inaccurate because of how it was done.
Just use a named query to do this instead of multitasking
such as
{ "multi_match" : { "query" : "query phrase here", "fields" : [ "name", "tag", "categorys" ], "operator" : "AND" }
translate it into a bool request named
"should": [ { "match": { "name": { "query": "query phrase here", "_name":"name_field" } } },{ "match": { "tag":{ "query": "query phrase here", "_name":"tag_field" } } },{ "match": { "categorys":{ "query": "query phrase here", "_name":"cat_field" } } } ]
it will return a result like this
{ "_index": "indexName", "_type": "type", "_id": "id", "_score": 0.27836448, "matched_queries": [ "tag_field" ] }, { "_index": "indexName", "_type": "type", "_id": "id", "_score": 0.27836448, "matched_queries": [ "name_field", "tag_field" ] }
source share