# Avoiding max clause count

**URL:** https://discuss.elastic.co/t/avoiding-max-clause-count/109991
**Category:** Elasticsearch
**Created:** [December 2, 2017, 12:31am UTC](https://discuss.elastic.co/t/avoiding-max-clause-count/109991 "2017-12-02T00:31:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Marty\_Loewenthal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marty_loewenthal/32/24409_2.png) [@Marty\_Loewenthal](https://discuss.elastic.co/u/Marty_Loewenthal)
#### Post date: [December 2, 2017, 12:31am UTC](https://discuss.elastic.co/t/avoiding-max-clause-count/109991/1 "2017-12-02T00:31:27Z")

</div>

Hello. I am in the process of migrating my team's Elasticsearch 2.4 clusters to Elasticsearch 5.  
I am changing the DSL to satisfy the breaking changes in ES 5. Most of our searches were unscored by using `filter`. Can I write my query such that it is un-scored and will avoid the max\_clause\_count.  
Es 2.4 Query:

```auto
    {
         "query": {
            "filtered": {
               "filter": {
                  "bool": {
                     "must": [{
                           "term": {
                              "_document.$type": "securitySettings"
                           }
                        }, {
                           "bool": {
                              "should": [{
                                    "terms": {
                                       "_linkIds.sectionIds": ["RR3EF4k", "RR3dIWo", Thousands of ids...]
                                    }
                                 }, {
                                    "terms": {
                                       "_linkIds.sectionIds": ["RR3ECt2"]
                                    }
                                 }
                              ]
                           }
                        }
                     ]
                  }
               }
            }
         }
    }

```

I changed it to this, but now realize this is scored and is not what we want.

```auto
  {
         "query": {
            "bool": {
               "must": [{
                     "term": {
                        "_document.$type": "securitySettings"
                     }
                  }, {
                     "bool": {
                        "should": [{
                              "terms": {
                                 "_linkIds.sectionIds": ["RR3EF4k", "RR3dIWo", Thousands of ids...]
                              }
                           }, {
                              "terms": {
                                 "_linkIds.sectionIds": ["RR3ECt2"]
                              }
                           }
                        ]
                     }
                  }
               ]
            }
         }
    }

```

Thanks for the help.

Edit: I have found Executing Filters: [https://www.elastic.co/guide/en/elasticsearch/reference/current/\_executing\_filters.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/_executing_filters.html)  
Is that the approach I should take, filter nested in bool with filters within?

---

<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: [December 30, 2017, 12:31am UTC](https://discuss.elastic.co/t/avoiding-max-clause-count/109991/2 "2017-12-30T00:31:33Z")

</div>

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