# maxClauseCount not working in elasticsearch

**URL:** <https://discuss.elastic.co/t/maxclausecount-not-working-in-elasticsearch/42125>\
**Category:** Elasticsearch\
**Created:** [February 18, 2016, 10:34am UTC](https://discuss.elastic.co/t/maxclausecount-not-working-in-elasticsearch/42125 "2016-02-18T10:34:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![r.ganeshbabu](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r.ganeshbabu](https://discuss.elastic.co/u/r.ganeshbabu)\
**Post date:** [February 18, 2016, 10:34am UTC](https://discuss.elastic.co/t/maxclausecount-not-working-in-elasticsearch/42125/1 "2016-02-18T10:34:40Z")

</div>

Hi All,

Our es\_item Index has higher document count as 438,799,356 and the size of index is 1.3 TB. We are using max\_expansions with match\_phrase\_prefix and below is the value I given in the GET query,  
**"21321312"**

In Our case We have an item\_code like "41484359" and it has two std\_extrn\_code (like "085601700343") with two different xcd ID's. The std\_extrn\_codes are same for two XCD ID's. Similarly there are so many std\_extrn\_codes for an single item\_code with different xcd ID's.

GET es\_item/item/\_search  
{  
"query": {  
"filtered": {  
"query": {  
"nested": {  
"query": {  
"match\_phrase\_prefix": {  
"STD\_EXTRN\_CODE\_STARTS": {  
"query": "0",  
\*\* "max\_expansions": 21321312\*\*  
} } },  
"path": "XCD"  
} },  
"filter": {  
"bool": {  
"must": [  
{  
"bool": {  
"should": [  
{  
"query": {  
"filtered": {  
"filter": {  
"terms": {  
"ITEM\_CODE\_RAW": [  
"41484359"  
]  
} } } } } ] } } ] } } } } }

Below is the error which I got when I execute the query in sense,

```
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[fMZhj1KGT7GanpGh3IE8jQ][es_item][0]: RemoteTransportException[[dayrhetfmi001_ETE_DATA][inet[/10.7.146.21:9261]][indices:data/read/search[phase/query]]]; 
nested: QueryPhaseExecutionException[[es_item][0]: query[filtered(filtered(ToParentBlockJoinQuery(filtered(XCD.STD_EXTRN_CODE.STD_EXTRN_CODE_STARTS:\"0*\")->cache(_type:__XCD)))->BooleanFilter(+BooleanFilter
(QueryWrapperFilter(ConstantScore(cache(ITEM_CODE.ITEM_CODE_RAW:41484359))))))->cache(+_type:item +org.elasticsearch.index.search.nested.NonNestedDocsFilter@abc67639)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: RuntimeException[org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024];
nested: TooManyClauses[maxClauseCount is set to 1024]; }{[ofHAUdT8TDuIigTUFMSCqg][es_item][1]: QueryPhaseExecutionException[[es_item][1]: query[filtered(filtered(ToParentBlockJoinQuery(filtered(XCD.STD_EXTRN_CODE.STD_EXTRN_CODE_STARTS:\"0*\")->cache(_type:__XCD))) ->BooleanFilter(+BooleanFilter(QueryWrapperFilter(ConstantScore(cache(ITEM_CODE.ITEM_CODE_RAW:41484359))))))
->cache(+_type:item+org.elasticsearch.index.search.nested.NonNestedDocsFilter@fd53b22c)],from[0],size[10]: Query Failed [Failed to execute main query]]; 
nested: RuntimeException[org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024]; nested: TooManyClauses[maxClauseCount is set to 1024]; }{[fMZhj1KGT7GanpGh3IE8jQ][es_item][2]:

```

I also changed the index.query.bool.max\_clause\_count value to 10240 in yml file but still i am getting the same error.

Should I have to change max\_expansions value also after changed the max\_clause\_count in yml file?

Please help us to resolve this error.

Thanks,  
Ganeshbabu R

---

<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:** [July 5, 2017, 11:15pm UTC](https://discuss.elastic.co/t/maxclausecount-not-working-in-elasticsearch/42125/2 "2017-07-05T23:15:19Z")

</div>


