Maybe I've missed something but it seems to me that highlight option require_field_match does not work correctly (ES 7.9.3 but I tested it with older versions also).
Very simple example follows:
Let's have following index with one document
POST test_index/_doc
{
"title": "just one",
"text": "something one two something else three"
}
I want to get documents where are all words "one, two, three" in text or all these words in title. It could be done in multiple ways but to avoid ambiguity let's use query_string.query. And of-course I want to get appropriate highlights to know why a document was matched.
So using following query the document is matched
GET test_index/_search
{
"highlight": {
"fields": {
"title": {},
"text": {}
}
},
"query": {
"query_string": {
"query": "title:(one AND two AND three) OR text:(one AND two AND three)"
}
}
}
But I get these highlights
"highlight" : {
"text" : [
"something <em>one</em> <em>two</em> something else <em>three</em>"
],
"title" : [
"just <em>one</em>"
]
}
I don't want to get title field highlighted this way because this field doen't match the query. Until now I've thought that this situation is the reason why parameter require_field_match exists so I try query:
GET test_index/_search
{
"highlight": {
"fields": {
"title": {
"require_field_match": "true"
},
"text": {
"require_field_match": "true"
}
}
},
"query": {
"query_string": {
"query": "title:(one AND two AND three) OR text:(one AND two AND three)"
}
}
}
But I get exactly same results with highligts for both text and title field. I am expecting to get just highlight for field text (because field title contains only one of those three words)
Does anybody know why it doesn't work as expected (even if the query is so simple) and how to get more precise highlights.
Thanks,
Zdenek