The following mapping and query DSL dict work OK when the version of ES is 7.10.2, but they never work where the version of ES is 7.16.3:
mappings = \
{
"mappings": {
"properties": {
"esdoc_text": {
"type": "text",
"term_vector": "with_positions_offsets",
"fields": {
"stemmed": {
"type": "text",
"analyzer": "english",
"term_vector": "with_positions_offsets",
}
}
}
}
}
}
- search 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
}
}
NB I am using the Python requests
module to do this, rather than the elasticsearch
"thin wrapper" module.
The "mapping" command is thus:
headers={'Content-type': 'application/json'}
requests.put(f'{ES_URL}/myindex', data=json.dumps(mappings), headers=headers)
and the "search" command is thus:
headers={'Content-type': 'application/json'}
requests.post(f'{ES_URL}/myindex/_search', data=json.dumps(data), headers=headers)
with version 7.10.2, setting self.text_field
to "esdoc_text" (field name) returns highlighted results using a standard analyser, and setting self.text_field
to "esdoc_text.stemmed" returns highlighted results using an english analyser.
but with version 7.16.3, with the identical mapping and identical query DSL dict, hits are produced, but they never contain a "highlight" key.
Has anyone got any idea why this might be? Has any modification crept in between 7.10.2 and 7.16.3 which might explain this? Anyone know how to change things so this works?