Showing unmatched word in elasticsearch results Showing unmatched word in elasticsearch results elasticsearch elasticsearch

Showing unmatched word in elasticsearch results


You could use named queries for this, by giving a name to each of your queries. In the results, each hit will feature a matched_queries array containing the names of the queries that matched (e.g. unmatched_query and strikethrough_query below). You can then use that info on the client-side to build a strikethrough list of words which didn't match.

{  "query": {    "bool": {      "should": [        {          "match": {            "content": {              "query": "unmatched",              "_name": "unmatched_query"            }          }        },        {          "match": {            "content": {              "query": "strikethrough",              "_name": "strikethrough_query"            }          }        }      ]    }  }}