# How to set max\_clause\_count in elasticsearch?

**URL:** <https://discuss.elastic.co/t/how-to-set-max-clause-count-in-elasticsearch/67376>\
**Category:** Elasticsearch\
**Created:** [November 28, 2016, 4:23pm UTC](https://discuss.elastic.co/t/how-to-set-max-clause-count-in-elasticsearch/67376 "2016-11-28T16:23:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![madhan](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@madhan](https://discuss.elastic.co/u/madhan)\
**Post date:** [November 28, 2016, 4:23pm UTC](https://discuss.elastic.co/t/how-to-set-max-clause-count-in-elasticsearch/67376/1 "2016-11-28T16:23:32Z")

</div>

I keep getting max\_clause\_count error in elasticsearch.

I'm directly passing more than 2000 id's and i'm getting max\_clause\_count error.

How to overcome this...

---

<div class="post-metadata">

**Author:** ![mikemccand](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@mikemccand](https://discuss.elastic.co/u/mikemccand)\
**Post date:** [November 28, 2016, 5:45pm UTC](https://discuss.elastic.co/t/how-to-set-max-clause-count-in-elasticsearch/67376/2 "2016-11-28T17:45:08Z")

</div>

Can you use `TermsQuery` instead of making a new query clause for each of your IDs?

Mike McCandless

---

<div class="post-metadata">

**Author:** ![madhan](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@madhan](https://discuss.elastic.co/u/madhan)\
**Post date:** [November 28, 2016, 5:49pm UTC](https://discuss.elastic.co/t/how-to-set-max-clause-count-in-elasticsearch/67376/3 "2016-11-28T17:49:25Z")

</div>

Thanks for your response.

Do you have any example or link to refer.

---

<div class="post-metadata">

**Author:** ![mikemccand](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@mikemccand](https://discuss.elastic.co/u/mikemccand)\
**Post date:** [November 28, 2016, 6:21pm UTC](https://discuss.elastic.co/t/how-to-set-max-clause-count-in-elasticsearch/67376/4 "2016-11-28T18:21:41Z")

</div>

See [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html)

Mike McCandless

---

<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 26, 2016, 6:21pm UTC](https://discuss.elastic.co/t/how-to-set-max-clause-count-in-elasticsearch/67376/5 "2016-12-26T18:21:49Z")

</div>

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