Hello,
for our highlighting currently we have a field "snippet" which contains all contenttext of all nested documents under du.content.content4b.contenttext
We want to remove the snippet field and use a nested query inside the highlight_query which we have defined as followed
{
"query": {
"bool": {
"must": [
{
"match": {
"du_key": "100010549"
}
}
]
}
},
"_source": false,
"highlight": {
"highlight_query": {
"bool": {
"should": [
{
"query_string": {
"query": "hund",
"default_field": "snippet"
}
},
{
"nested": {
"query": {
"query_string": {
"query": "hund",
"default_field": "du.content.content4b.contenttext"
}
},
"path": "du.content"
}
}
]
}
},
"fields": {
"du.content.content4b.contenttext": {
"fragment_size": 50,
"number_of_fragments": 3
},
"snippet": {
"fragment_size": 50,
"number_of_fragments": 3
}
}
}
}
Which returns the following result
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "hr-sd",
"_type": "searchdoc",
"_id": "100010549@2@0@0#0",
"_score": 1,
"highlight": {
"snippet": [
"Schwanenteich, am Ufer schwarzer Schwan, im Teich badet <em>Hund</em> Neufundländer"
],
"du.content.content4b.contenttext": [
"Schwanenteich, am Ufer schwarzer Schwan, im Teich badet <em>Hund</em> Neufundländer"
]
}
}
]
}
Which seems okay for us. But if we used wildcards "hund*" instead of "hund"
{
"query": {
"bool": {
"must": [
{
"match": {
"du_key": "100010549"
}
}
]
}
},
"_source": false,
"highlight": {
"highlight_query": {
"bool": {
"should": [
{
"query_string": {
"query": "hund*",
"default_field": "snippet"
}
},
{
"nested": {
"query": {
"query_string": {
"query": "hund*",
"default_field": "du.content.content4b.contenttext"
}
},
"path": "du.content"
}
}
]
}
},
"fields": {
"du.content.content4b.contenttext": {
"fragment_size": 50,
"number_of_fragments": 3
},
"snippet": {
"fragment_size": 50,
"number_of_fragments": 3
}
}
}
}
the result looks different and only returns highlight: "snippet"
"hits": [
{
"_index": "hr-sd",
"_type": "searchdoc",
"_id": "100010549@2@0@0#0",
"_score": 1,
"highlight": {
"snippet": [
"Schwanenteich, am Ufer schwarzer Schwan, im Teich badet <em>Hund</em> Neufundländer"
]
}
}
]
Do we make any mistake or is this a known bug?