# Подсветка фраз со стоп-словами при match\_phrase поиске

**URL:** <https://discuss.elastic.co/t/match-phrase/31630>\
**Category:** Вопросы на русском языке\
**Created:** [October 5, 2015, 12:48pm UTC](https://discuss.elastic.co/t/match-phrase/31630 "2015-10-05T12:48:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![strikerdimabel](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@strikerdimabel](https://discuss.elastic.co/u/strikerdimabel)\
**Post date:** [October 5, 2015, 12:48pm UTC](https://discuss.elastic.co/t/match-phrase/31630/1 "2015-10-05T12:48:21Z")

</div>

Добрый день!

Возникла проблема, связанная с подсветкой результатов поиска: никакой подсветки вообще не выдаётся.  
Она имеет место, если:

1. к полю привязан термвектор ("with\_positions\_offsets");
2. ищем фразу;
3. в фразе есть хотя бы одно стоп-слово.

**Пример.**

Создание индекса:

```
PUT twitter
{
  "settings": {
    "analysis": {
      "analyzer": {
        "default": {
	  "type": "standard",
	  "stopwords": ["and", "the"] 
            }
      }
    }
  },
  "mappings": {
    "tweet" : {
      "properties": {
        "text" : {
	  "type": "string",
	  "term_vector": "with_positions_offsets"
        }
      }
    }
  }
}

```

Добавление записи:

```
PUT twitter/tweet/1
{
  "text" : "this and end"
}

```

Поиск:

```
POST /twitter/tweet/_search
{
  "query": { 
    "match_phrase": {
      "text": "this and end"
    }
  },
  "highlight": {
    "fields" : {
      "text" : {}
    }
  }
}

```

Результат:

```
"hits": [
  {
    "_index": "twitter",
    "_type": "tweet",
    "_id": "1",
    "_score": 0.38356602,
    "_source": {
       "text": "this and end"
     }
  }
]

```

Можно ли что-нибудь с этим сделать? Пока что единственным нашим решением было убрать все стоп-слова.

---

<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:** [October 5, 2015, 1:10pm UTC](https://discuss.elastic.co/t/match-phrase/31630/2 "2015-10-05T13:10:46Z")

</div>

Это очень старая и сложная проблема, см тут - [https://github.com/elastic/elasticsearch/issues/2157](https://github.com/elastic/elasticsearch/issues/2157)

---

<div class="post-metadata">

**Author:** ![strikerdimabel](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@strikerdimabel](https://discuss.elastic.co/u/strikerdimabel)\
**Post date:** [November 24, 2015, 11:00am UTC](https://discuss.elastic.co/t/match-phrase/31630/3 "2015-11-24T11:00:24Z")

</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:** [July 6, 2017, 1:50pm UTC](https://discuss.elastic.co/t/match-phrase/31630/4 "2017-07-06T13:50:30Z")

</div>


