I am using elasticsearch highlight for sometime now and having some problems. here is the highlight query:
"highlight" : {
"pre_tags" : [ "<span class=\"mark\">" ],
"post_tags" : [ "</span>" ],
"order" : "score",
"encoder" : "html",
"require_field_match" : false,
"fields" : {
"*" : { }
}
}
I am specifying * in fields because I need highlighting for all possible fields and do not want to specify them all. The problem is it that if I use field query it highlights also fields that were not queried, For example if I query for:
Name:Macdonalds
It will highlight also:
Name:**Macdonalds**
Description: **macdonalds** fast food...
I am using query_string query, and I cannot set require_field_match to true since I am also searching free test in all fields and if I set this parameter to true it does not highlight anything...
Any suggestions? Has someone stumble on such issue?
Well, I have managed to workaround this issue (following @Will comment) When specifying explicitly all fields you want highlighting on in the query itself and setting
require_field_match" : true
The highlight works as expected :) a little strange... but works. This way it has an issue highlighting fields that are not strings, so pay attention.