19

I have a pretty big terms query in elasticsearch, so I get too_many_clauses: maxClauseCount is set to 1024

I tried increasing it in the elasticsearch.yml by

index:
query:
bool:
max_clause_count: 10240

and via

curl -XPUT "http://localhost:9200/plastic/_settings" -d '{ "index" : { "max_clause_count" : 10000 } }'

but nothing worked. My index is named plastic.

Evo_x
  • 2,997
  • 5
  • 24
  • 40

4 Answers4

27

In Elasticsearch 5, index.query.bool.max_clause_count has been deprecated/removed.

Insert in your elasticsearch.yml file indices.query.bool.max_clause_count : n instead (where n - new supported number of clauses).

NOTE: Here is link to documentation.

Naman
  • 27,789
  • 26
  • 218
  • 353
puma
  • 318
  • 2
  • 7
  • 4
    It hasn't been deprecated, it's been removed. Your Elasticsearch instance won't start. At least it happens in 5.2.2 – Tom Raganowicz Mar 30 '17 at 05:53
  • In ES 5, you want to use `indices.query.bool.max_clause_count: 2500` and restart server. – naoko Aug 13 '18 at 17:50
  • As of ES 8, it's deprecated and has no effect: https://www.elastic.co/guide/en/elasticsearch/reference/8.9/search-settings.html#search-settings – matt burns Aug 25 '23 at 09:55
20

Background

NOTE: The advice given in this answer only applies to versions of Elasticsearch below 5.5. The method described references a property that was eventually removed in 5.5.

Search Settings

The setting index.query.bool.max_clause_count has been removed. In order to set the maximum number of boolean clauses indices.query.bool.max_clause_count should be used instead.


Original Answer

Add the following:

index.query.bool.max_clause_count: 10240

To the file elasticsearch.yml on each node of the cluster, then of course, restart the nodes (any change in the config file needs a restart).

slm
  • 15,396
  • 12
  • 109
  • 124
Andrei Stefan
  • 51,654
  • 6
  • 98
  • 89
  • 1
    For the ES5, look answer below. – Tom Raganowicz Mar 30 '17 at 05:52
  • This property was removed the subsequent releases of ES so this A'er is no longer the proper way to address this change in Elasticsearch 5 and higher. – slm Jun 07 '19 at 15:09
  • As of ES 8, it's deprecated and has no effect: https://www.elastic.co/guide/en/elasticsearch/reference/8.9/search-settings.html#search-settings – matt burns Aug 25 '23 at 09:55
6

this can also be achieved by updating configuration inside elasticsearch.yml file (inside config folder of elastic installation)

indices.query.bool.max_clause_count: 4096
Pravin Bansal
  • 4,315
  • 1
  • 28
  • 19
4

If you're looking to make changes to your cloud elasticsearch.yml file in a cloud deployment, see Add Elasticsearch user settings for the steps to follow to achieve this and the changes you're allowed to make. However, note that there is a limit to the settings you're allowed to change in the cloud deployment.

If you're looking to make changes to your local cluster, you can make the change directly in your elasticsearch.yml file located at "elasticsearch-x.x.x/config/elasticsearch.yml" by simply adding a line of the required setting to the file. For example, if you want to change indices.query.bool.max_clause_count from it's default value of 1024 to 4096, you can add the line indices.query.bool.max_clause_count: 4096 to your elasticsearch.yml file.

Remember that indices.query.bool.max_clause_count is 1024 be default, though the elasticsearch.yml does explicitly contain a line stating this value, yet it would resort to 1024 being the default value. So the only way to change this value is that you will explicitly add the line "indices.query.bool.max_clause_count: 4096". By including this line and specifying your preferred value in your own elasticsearch.yml file, you have ultimately modified the value "indices.query.bool.max_clause_count" for your cluster.

The following image shows how this line was appended to a sample elasticsearch.yml file:

enter image description here

After adding this line and saving the changes to your elasticsearch.yml file, start Elasticsearch, and then Kibana (if you're interacting with ES with Kibana). You can verify your setting by running the command: GET /_cluster/settings/?include_defaults in Kibana or curl -XGET "http://localhost:9200/_cluster/settings/?include_defaults" in your command line. Then, look for max_clause_count in the command's output to verify the value of indices.query.bool.max_clause_count

Val
  • 207,596
  • 13
  • 358
  • 360
Olamide O
  • 41
  • 1
  • Same article is published in a bit more details here: https://medium.com/@olamideolajidew/making-cluster-wide-changes-to-elasticsearch-by-modifying-the-elasticsearch-yml-file-a0026bd1b7bf – Olamide O Feb 26 '20 at 14:52