This is an issue with Elastic Search 2.1.1 and same on 2.2.0.
I have this record indexed in elastic :
{ "WordB" : "Cat", "WordC" : "Dog", "WordA" : "Black", "message" : "Black Dog", }
When I run the following query :
{ "query" : { "bool" : { "must" : { "bool" : { "should" : [{ "multi_match" : { "query" : "Black Dog", "fields" : [ "WordA", "WordB", "WordC", "message" ], "type" : "phrase", "analyzer" : "default_search" } } ] } } } }, "highlight" : { "pre_tags" : [ "<b>" ], "post_tags" : [ "</b>" ], "fragment_size" : 0, "number_of_fragments" : 0, "require_field_match" : false, "fields" : { "WordA" : {}, "WordB" : {}, "WordC" : {}, "message" : {} } } }
I get the following result :
{ "took" : 11, "timed_out" : false, "_shards" : { "total" : 190, "successful" : 190, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 1.9719523, "hits" : [{ "_index" : "fts-english", "_type" : "Document", "_id" : "AVJk37BCIfOJ7fqrcZCp", "_score" : 1.9719523, "_source" : { "WordB" : "Cat", "WordC" : "Dog", "WordA" : "Black", "message" : "Black Dog" }, "highlight" : { "WordC" : [ "<b>Dog</b>" ], "WordA" : [ "<b>Black</b>" ], "message" : [ "<b>Black</b> <b>Dog</b>" ] } } ] }
}
But I searched for a phrase, so why do I get highlighting of individual words in fields that don 't contain the full phrase? I expect to get in this case only the "message" field highlighted but not the other two fields.
I should also mention that:
- Other records containing just the word "Black" are not returned by the query, which indicates that the phrase query itself runs correctly, and the issue is only in the highlighting.
- The same worked correctly on Elastic Search version 1.6.0, and I am seeing this issue only with version 2.1.1 and 2.2.0.