Description
Elasticsearch Version
7.16.3
Installed Plugins
No response
Java Version
bundled
OS Version
Linux (Mint 20), W10
Problem Description
The same mappings and query DSL dict which work fine to produce multi-word, multi-colour highlighting in v 7.10.2 don't seem to work with v 7.16.3: on both Linux and W10 I have had to revert to 7.10.2. I'd love it if an expert could check on what's going on: maybe there has been a substantive documented change between the two ES versions.
I had a look at the latest version (8.0) for this here, but nothing jumped out at me. However, in the section on fvh and multi-fields I noticed that nothing was said about using pre-tags
and post-tags
. The point about my example is that different terms are highlighted with different colours (in fact backgrounds).
I have posted this in the ES forum. No replies after a few days, hence my opening of an issue here.
Steps to Reproduce
Given this mapping:
mappings = \
{
"mappings": {
"properties": {
"esdoc_text": {
"type": "text",
"term_vector": "with_positions_offsets",
"fields": {
"stemmed": {
"type": "text",
"analyzer": "english",
"term_vector": "with_positions_offsets",
}
}
}
}
}
}
and this query DSL dict:
data = \
{
'query': {
'simple_query_string': {
'query': self.search_string,
'fields': [
self.text_field
]
}
},
'highlight': {
'fields': {
self.text_field: {
'type': 'fvh',
'pre_tags': [
'<span style="background-color: yellow">',
'<span style="background-color: skyblue">',
'<span style="background-color: lightgreen">',
'<span style="background-color: plum">',
'<span style="background-color: lightcoral">',
'<span style="background-color: silver">',
],
'post_tags': [
'</span>', '</span>', '</span>',
'</span>', '</span>', '</span>',
]
}
},
'number_of_fragments': 0
}
}
... I get beautiful highlighted results using 7.10.2. But using 7.16.3, the hits are returned, but there is no "highlight" key at all in the returned response.json().
NB in the above, clearly and as one might surmise from the mapping, self.text_field
is set to either "esdoc_text" (for standard analyser results) or "esdoc_text.stemmed" (for english stemmer analyser results).
Logs (if relevant)
No response