# How to reduce multiple conditions in ES

**URL:** https://discuss.elastic.co/t/how-to-reduce-multiple-conditions-in-es/219052
**Category:** Elasticsearch
**Created:** [February 12, 2020, 5:29pm UTC](https://discuss.elastic.co/t/how-to-reduce-multiple-conditions-in-es/219052 "2020-02-12T17:29:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ramesh\_balasubramani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramesh_balasubramani/32/53173_2.png) [@Ramesh\_balasubramani](https://discuss.elastic.co/u/Ramesh_balasubramani)
#### Post date: [February 12, 2020, 5:29pm UTC](https://discuss.elastic.co/t/how-to-reduce-multiple-conditions-in-es/219052/1 "2020-02-12T17:29:39Z")

</div>

```
GET /logs*/_search
{
   "from":0,
   "query":{
      "bool":{
         "filter":[
            {
               "range":{
                  "@timestamp":{
                     "gte":"2020-02-10T11:13:19.7684961Z",
                     "lte":"2020-02-11T11:13:19.7684961Z"
                  }
               }
            }
         ],
         "must":[
            {
               "bool":{
                  "must_not":[
                     {
                        "match_phrase":{
                           "message":{
                              "query":"System32"
                           }
                        }
                     },
                     
                     {
                        "match_phrase":{
                           "message":{
                              "query":"212.118.14.45"
                           }
                        }
                     },
                 
                     {
                        "match_phrase":{
                           "message":{
                              "query":" stopped state."
                           }
                        }
                     },
                     {
                        "match_phrase":{
                           "message":{
                              "query":" running state"
                           }
                        }
                     },
                     {
                        "match_phrase":{
                           "message":{
                              "query":" Share Name: \\\\*\\DLO-EBackup"
                           }
                        }
                     }
					 .
					 .
					 .
					 etc.,
					 .
					 .
					 .
					 .
					 .
                     {
                        "match_phrase":{
                           "message":{
                              "query":"WFO15Installation"
                           }
                        }
                     },
                     {
                        "match_phrase":{
                           "message":{
                              "query":"Windows\\SysWOW64"
                           }
                        }
                     },
                     {
                        "match_phrase":{
                           "message":{
                              "query":"Bitvise"
                           }
                        }
                     }
                  ]
               }
            }
         ]
      }
   },
   "size":10,
   "sort":[
      {
         "@timestamp":{
            "order":"desc"
         }
      }
   ]  
}

```

In the above query, I used multiple times match\_phrase. how to reduce multiple match\_phrase? because in production while querying to ES response is very slow.

Thank You !

---

<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: [March 11, 2020, 5:43pm UTC](https://discuss.elastic.co/t/how-to-reduce-multiple-conditions-in-es/219052/2 "2020-03-11T17:43:56Z")

</div>

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