# Optimal value for indices.query.bool.max\_clause\_count

**URL:** <https://discuss.elastic.co/t/optimal-value-for-indices-query-bool-max-clause-count/117645>\
**Category:** Elasticsearch\
**Created:** [January 30, 2018, 3:06pm UTC](https://discuss.elastic.co/t/optimal-value-for-indices-query-bool-max-clause-count/117645 "2018-01-30T15:06:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ffoysal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ffoysal/32/21037_2.png) [@ffoysal](https://discuss.elastic.co/u/ffoysal)\
**Post date:** [January 30, 2018, 3:06pm UTC](https://discuss.elastic.co/t/optimal-value-for-indices-query-bool-max-clause-count/117645/1 "2018-01-30T15:06:20Z")

</div>

We have 200K documents and each one has a title field. When we search for a single letter, it will generate huge number of search hits. Just wondering what value should we chose for the setting indices.query.bool.max\_clause\_count

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 30, 2018, 3:21pm UTC](https://discuss.elastic.co/t/optimal-value-for-indices-query-bool-max-clause-count/117645/2 "2018-01-30T15:21:20Z")

</div>

> [@ffoysal](#):
>
> Just wondering what value should we chose for the setting

That setting is a protection against abusive queries with many search terms. It is unrelated to the number of search hits any query might produce. What problem are you trying to solve?

---

<div class="post-metadata">

**Author:** ![ffoysal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ffoysal/32/21037_2.png) [@ffoysal](https://discuss.elastic.co/u/ffoysal)\
**Post date:** [January 30, 2018, 6:29pm UTC](https://discuss.elastic.co/t/optimal-value-for-indices-query-bool-max-clause-count/117645/3 "2018-01-30T18:29:41Z")

</div>

> [@ffoysal](#):
>
> max\_clause

We were using hibernatesearch and set this property hibernate.search.default.booleanQuery.MaxClauseCount= 4096

For some regex queries with single character it was throwing exception of maxClauseCount exceed.

Just wondering if we are going to hit the same excepetion again with elasticsearch.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 30, 2018, 6:42pm UTC](https://discuss.elastic.co/t/optimal-value-for-indices-query-bool-max-clause-count/117645/4 "2018-01-30T18:42:23Z")

</div>

The limits are there for a reason - many clauses = many lookups = many disk seeks.  
Assuming a worst case-scenario of a spinning disk with an average 5ms seek time you can see how thousands of terms will slow down your searches. Obviously file system caching alleviates some of this cost but we can't assume all of the index is cachable in the default settings.

---

<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:** [February 27, 2018, 6:42pm UTC](https://discuss.elastic.co/t/optimal-value-for-indices-query-bool-max-clause-count/117645/5 "2018-02-27T18:42:27Z")

</div>

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