# Highlight problem on fuzzy search

**URL:** <https://discuss.elastic.co/t/highlight-problem-on-fuzzy-search/214989>\
**Category:** Elasticsearch\
**Created:** [January 14, 2020, 12:54pm UTC](https://discuss.elastic.co/t/highlight-problem-on-fuzzy-search/214989 "2020-01-14T12:54:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Casper\_Thrane](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/casper_thrane/32/49777_2.png) [@Casper\_Thrane](https://discuss.elastic.co/u/Casper_Thrane)\
**Post date:** [January 14, 2020, 12:54pm UTC](https://discuss.elastic.co/t/highlight-problem-on-fuzzy-search/214989/1 "2020-01-14T12:54:56Z")

</div>

I have a problem with highlighting, on a fuzzy search. The problem is the highlighting is a char to long.

See example below.

```auto
PUT test
{
"settings": {
  "index": {
      "analysis": {
        "analyzer": {
          "my_suggest": {
            "type": "custom",
            "tokenizer": "my_tokenizer",
            "filter": [
              "danish_stop",
              "danish_stemmer",
              "lowercase",
              "remove_duplicates"
            ]
          }
        },
        "filter": {
          "danish_stemmer": {
            "type": "stemmer",
            "language": "danish"
          },
          "danish_stop": {
            "type": "stop",
            "stopwords": "_danish_"
          }
        },
        "tokenizer": {
          "my_tokenizer": {
            "type": "edge_ngram",
            "min_gram": 3,
            "max_gram": 15,
            "token_chars": [
              "letter",
              "digit"
            ]
          }
        }

      }
    }
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "text",
        "fields": {
          "suggest": {
            "type": "text",
            "analyzer": "my_suggest",
            "fielddata": true
          }
        }
      }
    }
  }
}

PUT test/_doc/1
{
  "title": "affaldsregister",
}

PUT test/_doc/2
{  
  "title": "affaldsregulativ",
}

GET test/_search
{
  "_source": "title", 
  "query": {
    "match": {
      "title.suggest": {
        "query": "affaldsreg",
        "fuzziness": 1
      }
    }
  },
  "highlight": {
    "fields": {
      "title.suggest": {
      }
    }
  }
}

```

It will highlight the char after the 'g'. But if I remove the fuzziness, it highlights until 'g'.

---

<div class="post-metadata">

**Author:** ![Casper\_Thrane](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/casper_thrane/32/49777_2.png) [@Casper\_Thrane](https://discuss.elastic.co/u/Casper_Thrane)\
**Post date:** [January 15, 2020, 12:41pm UTC](https://discuss.elastic.co/t/highlight-problem-on-fuzzy-search/214989/2 "2020-01-15T12:41:56Z")

</div>

Anyone? All sugggestions are welcome 🙂

---

<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:** [February 12, 2020, 12:41pm UTC](https://discuss.elastic.co/t/highlight-problem-on-fuzzy-search/214989/3 "2020-02-12T12:41:58Z")

</div>

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