# Как обрабатывать фразу из одинаковых слов?

**URL:** <https://discuss.elastic.co/t/topic/87136>\
**Category:** Вопросы на русском языке\
**Created:** [May 25, 2017, 2:08pm UTC](https://discuss.elastic.co/t/topic/87136 "2017-05-25T14:08:48Z")\
**Posts on this page:** 1\
**Showing post:** 8

<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:** [May 30, 2017, 1:30pm UTC](https://discuss.elastic.co/t/topic/87136/8 "2017-05-30T13:30:38Z")

</div>

> Реализовать можно и просто двумя запросами конечно...

Да, я думаю проще одним запросом но по двум полям:

```auto
DELETE test
PUT test
{
  "settings": {
    "analysis": {
      "char_filter": {
        "replace_dash_char_filter": {
          "type": "mapping",
          "mappings": [
            "- => _"
          ]
        }
      },
      "analyzer": {
        "my_analyzer": {
          "char_filter": [
            "replace_dash_char_filter"
          ],
          "tokenizer": "standard",
          "filter": [
            "lowercase"
          ]
        }
      }
    }
  },
  "mappings": {
    "doc": {
      "properties": {
        "message": {
          "type": "text",
          "analyzer": "my_analyzer",
          "fields": {
            "standard": {
              "type": "text",
              "search_analyzer": "my_analyzer", 
              "analyzer": "standard"
            }
          }
        }
      }
    }
  }
}

PUT test/doc/_bulk?refresh
{"index":{"_id":1}}
{"message" : "клен-дуб и грибы"}
{"index":{"_id":2}}
{"message" : "Клен или дуб, вот в чем вопрос"}
{"index":{"_id":3}}
{"message" : "Стоит дуб-дубом, ничего не отвечает"}
{"index":{"_id":4}}
{"message" : "Дуб-дуб это вам не клен и дуб"}

GET test/doc/_search
{
  "query": {
    "multi_match": {
      "query": "клен-дуб",
      "fields": ["message^2", "message.standard"]
    }
  }
}

GET test/doc/_search?explain
{
  "query": {
    "multi_match": {
      "query": "клен",
      "fields": ["message^2", "message.standard"]
    }
  }
}

```

---

_[View the full topic](https://discuss.elastic.co/t/topic/87136)._
