# Highlight issue on field with custom analyzer

**URL:** <https://discuss.elastic.co/t/highlight-issue-on-field-with-custom-analyzer/231061>\
**Category:** Elasticsearch\
**Created:** [May 5, 2020, 12:27am UTC](https://discuss.elastic.co/t/highlight-issue-on-field-with-custom-analyzer/231061 "2020-05-05T00:27:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasoncodingguru](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@jasoncodingguru](https://discuss.elastic.co/u/jasoncodingguru)\
**Post date:** [May 5, 2020, 12:27am UTC](https://discuss.elastic.co/t/highlight-issue-on-field-with-custom-analyzer/231061/1 "2020-05-05T00:27:47Z")

</div>

Hey guys,

We are having issues on fields with custom analyzer when using highlight feature. The field value is like "1kg", the customer analyzer will process and generate tokens including "1", "kg", "kilogram" as we also have synonym for "kg".

The mapping of the field is like below:

```auto
      "volumesize": {
            "type": "text",
            "fielddata": false,
            "analyzer": "analyzer_search",
            "term_vector": "with_positions_offsets",
            "index_options": "offsets"
      }

```

When we run below query with hightlight:

```auto
      "highlight": {
    "fields": {
      "displayname": {
        "type": "fvh"
      },
      "volumesize": {
        "type": "fvh"
      }
    }
  },
  "query": {
    "bool": {
      "must": [
        {
          "multi_match": {
            "analyzer": "analyzer_search",
            "fields": [
              "volumesize",
              "productname",
            ],
            "query": "1kg coffee",
            "type": "cross_fields",
            "auto_generate_synonyms_phrase_query": "false"
          }
        }
      ]
    }
  }
  }
} 

```

The highlight on field "vollumesize" returns something like `<em>1</em>k<em>g</em>` which is not correct as the whole term "1kg" should be highlighted. we tried to use different highlighter like "unified", none of them works.

Can anyone please help?

Thanks a lot

Jason

---

<div class="post-metadata">

**Author:** ![jasoncodingguru](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@jasoncodingguru](https://discuss.elastic.co/u/jasoncodingguru)\
**Post date:** [May 6, 2020, 11:40am UTC](https://discuss.elastic.co/t/highlight-issue-on-field-with-custom-analyzer/231061/2 "2020-05-06T11:40:46Z")

</div>

does anyone have any idea please?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 3, 2020, 11:44am UTC](https://discuss.elastic.co/t/highlight-issue-on-field-with-custom-analyzer/231061/3 "2020-06-03T11:44:05Z")

</div>

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