DBAtlas · Database operations atlas

too_many_clauses: too_many_clauses: maxClauseCount is set to 1024 (query contains too many clauses)

Elasticsearch

What does it mean?

A query exceeded the maximum allowed number of Lucene clauses. In ES 8.x this limit is not fixed; it is calculated automatically from the node's heap size and search thread count (it can drop to 1024 on small-heap nodes), and the error message shows the current value. Very large bool queries and queries that expand to many terms trigger it.

Why does it happen?

Programmatically generated bool queries with thousands of should/must clauses; wildcard/prefix/fuzzy/query_string queries expanding to many terms; deeply nested bool structures. Note: the terms query (a value list on a single field) is not subject to this limit; its cap is index.max_terms_count (default 65,536).

How to fix it

Simplify the query: convert many term clauses on a single field into one terms query (or a terms lookup for large lists). Use more specific query types or index_prefixes/keyword fields instead of wildcard/prefix. In ES 8.x the indices.query.bool.max_clause_count setting is deprecated and ignored; the way to raise the limit is to increase the node heap. Review the query generation logic.

Open in DBAtlas →

More from this engine