Mapping the query to the highlight using FVH

Thanks for the write-up.
One approach for more transparency into what search terms matched might be to use the highlighter that ships with the annotated_text field which is installed as an extra plugin. Although it's designed for use on annotated_text fields it also works with text fields and uses a markdown-like syntax for adding annotations to text e.g. given this doc:

{
	"text": "The new hot technology has emerged!"
}

and this query

{
	"query": {
		"bool": {
			"should": [
				{"match": {"text": "fabulous"}},
				{"match": {"text": "new"}}
			],
			"must": [
				{"match": {"text": "technology"}},
				{"wildcard": {"text": "emerg*"}}
			]
		}
	},
	"highlight": {
		"type": "annotated",
		"fields": {
			"text": {}
		}
	}
}

The marked-up result includes which terms matched a section of text:

        "highlight": {
          "text": [
            "The [new](_hit_term=new) hot [technology](_hit_term=technology) has [emerged](_hit_term=text%3Aemerg*)!"
          ]
        }
2 Likes