# Range filter and max\_clause\_count

**URL:** <https://discuss.elastic.co/t/range-filter-and-max-clause-count/155584>\
**Category:** Elasticsearch\
**Created:** [November 6, 2018, 4:27pm UTC](https://discuss.elastic.co/t/range-filter-and-max-clause-count/155584 "2018-11-06T16:27:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DmitriV](https://avatars.discourse-cdn.com/v4/letter/d/f6c823/32.png) [@DmitriV](https://discuss.elastic.co/u/DmitriV)\
**Post date:** [November 6, 2018, 4:27pm UTC](https://discuss.elastic.co/t/range-filter-and-max-clause-count/155584/1 "2018-11-06T16:27:51Z")

</div>

Hi,

I am having trouble with a use-case where I need to filter the content of an index based on multiple x-coordinate ranges. The number of ranges can go up to 500 000 distinct intervals (dynamically defined by the end-user). Obviously I ran into the max\_clause\_count error when using the ranges in query context. From reading the docs I was given to understand the underlying Lucene engine does not run into that limitation when running a large number of clauses in filter context.

I have tried as follows, however I am still running into the max\_clause\_count error:

```
"query": {
    "bool": {
        "filter": [
            {"bool": {
                  "should": <an array of 500 000 range expressions>
            }}
        ]
    }
}

```

Is this the right way to use a range expression in filter context?

---

<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 4, 2018, 4:27pm UTC](https://discuss.elastic.co/t/range-filter-and-max-clause-count/155584/2 "2018-12-04T16:27:54Z")

</div>

Closed on December 4, 2018, 4:27pm UTC

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