# Поиск по разным полям

**URL:** <https://discuss.elastic.co/t/topic/129452>\
**Category:** Вопросы на русском языке\
**Created:** [April 25, 2018, 10:18am UTC](https://discuss.elastic.co/t/topic/129452 "2018-04-25T10:18:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Khuman](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@Khuman](https://discuss.elastic.co/u/Khuman)\
**Post date:** [April 25, 2018, 10:18am UTC](https://discuss.elastic.co/t/topic/129452/1 "2018-04-25T10:18:22Z")

</div>

Всем привет.  
Помогите организовать поиск по нескольким полям. Есть индекс вот с таким маппингом:  
{  
"russian\_common": {  
"mappings": {  
"\_doc": {  
"fullname": {  
"type": "text",  
"copy\_to": ["my\_all\_fields"],  
"analyzer": "russian"  
},  
"about": {  
"type": "text",  
"copy\_to": ["my\_all\_fields"],  
"analyzer": "russian"  
},  
"marriage": {  
"type": "text",  
"copy\_to": ["my\_all\_fields"],  
"analyzer": "russian"  
},  
"my\_all\_fields": {  
"type": "text",  
"analyzer": "russian"  
}  
}

Мне надо реализовать запрос, который ищет сначала по полю my\_all\_field, например, "Сергей", а потом по полю marriage, например, "холост" Пока, с помощью bool запросов у меня получается поиск по полю my\_all\_field, а добиться того, чтобы и потом по полю marriage выполнялся поиск - не получается. Вот пример одного из моих запросов:

```
get russian_common/_search
{
     "from": 0,
     "size": 50,
      "query": {
          "bool":{ 
              "must": [{"match": {"about": {"query": "холост"}}}], 
              "should": [{"match": {"my_all_fields": {"query": "Сергей"}}}]
     }
  }
}

```

Помогите с примером.  
Спасибо!

---

<div class="post-metadata">

**Author:** ![Khuman](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@Khuman](https://discuss.elastic.co/u/Khuman)\
**Post date:** [April 25, 2018, 1:31pm UTC](https://discuss.elastic.co/t/topic/129452/2 "2018-04-25T13:31:41Z")

</div>

Найдено решение.

```
get russian_common/_search
        {
           "from": 0,
           "size": 50,
           "query": {
           "bool" : {
           "must" : [
                 {"match": {"my_all_fields": {"query": "Сергей",
                                                        "fuzziness": 0.5,
                                                        "prefix_length": 2}}},
                 {"match": {"about": {"query": "наука",
                                               "fuzziness": 0.5,
                                               "prefix_length": 2}}
                 } 
               ]
             }
           }
         }
```

---

<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:** [May 23, 2018, 1:31pm UTC](https://discuss.elastic.co/t/topic/129452/3 "2018-05-23T13:31:43Z")

</div>

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