# При подсветке результатов, текст не обрамляется тегами

**URL:** <https://discuss.elastic.co/t/topic/95036>\
**Category:** Вопросы на русском языке\
**Created:** [July 29, 2017, 8:10am UTC](https://discuss.elastic.co/t/topic/95036 "2017-07-29T08:10:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bio/32/76409_2.png) [@bio](https://discuss.elastic.co/u/bio)\
**Post date:** [July 29, 2017, 8:10am UTC](https://discuss.elastic.co/t/topic/95036/1 "2017-07-29T08:10:30Z")

</div>

Добрый день!

Подскажите, почему-то нормально не отрабатывает highlight результатов  
Данные для воспроизведения [тут](https://gist.github.com/AsanovRuslan/4c34c570cd4952cef4ae3f7d8738d153)

В чём может быть проблема ?

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [July 31, 2017, 6:35pm UTC](https://discuss.elastic.co/t/topic/95036/2 "2017-07-31T18:35:54Z")

</div>

Да, plain hightlighter и ngrams не очень дружат. Лучше, переключиться на fvh или postings и при поиске не пропускать через ngram. Короче, как-то так:

```auto
PUT test
{
  "settings": {
    "number_of_shards": 1,
    "analysis": {
      "tokenizer": {
        "ngram": {
          "type": "ngram",
          "min_gram": "2",
          "max_gram": "20"
        }
      },
      "analyzer": {
        "ngram": {
          "type": "custom",
          "filter": [
            "lowercase",
            "unique"
          ],
          "tokenizer": "ngram"
        },
        "my_search": {
          "type": "custom",
          "tokenizer": "keyword",
          "filter": [
            "lowercase"
          ]
        }
      }
    }
  },
  "mappings": {
    "_default_": {
      "properties": {
        "email": {
          "type": "text",
          "analyzer" : "ngram",
          "search_analyzer": "my_search",
          "index_options" : "offsets"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![bio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bio/32/76409_2.png) [@bio](https://discuss.elastic.co/u/bio)\
**Post date:** [August 1, 2017, 7:14am UTC](https://discuss.elastic.co/t/topic/95036/3 "2017-08-01T07:14:12Z")

</div>

Спасибо!

---

<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:** [August 29, 2017, 7:14am UTC](https://discuss.elastic.co/t/topic/95036/4 "2017-08-29T07:14:17Z")

</div>

Closed on August 29, 2017, 7:14am UTC

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