Multi-field mapping/search "highlighting" difference between 7.10.2 and 7.16.3?

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?

For some reason I can't now edit this post.

Just to add: I have now ascertained that this is indeed the case in both Linux and W10: in both cases, highlighting with the above dicts fails to happen with 7.16.3 but works perfectly with 7.10.2.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.