The Error
Your search query fails with one of these exceptions:
org.apache.lucene.search.IndexSearcher$TooManyClauses: maxClauseCount is set to 1024
org.apache.lucene.search.IndexSearcher$TooManyNestedClauses: Query contains too many nested clauses; maxClauseCount is set to 1024
This means your query expanded into more than 1,024 individual boolean clauses, hitting the Lucene safety limit.
What Causes This
Every Solr query gets broken down into boolean clauses. A simple q=hello is 1 clause. But queries can expand into hundreds or thousands of clauses:
Common triggers:
- Drupal Search API Solr — expands each search term across many fields with boosting, synonym, and phrase clauses. A 5-word search easily exceeds 1,024 clauses. This is the most common cause of this error.
- Wildcard queries —
*termor short prefixes likea*match thousands of index terms, each becoming a clause. - Synonym explosion — many synonyms per word multiplied across query terms.
- Large OR filter lists —
fq=id:(1 OR 2 OR ... OR 2000)creates one clause per value.
How To Fix This
Where the Limit Is Set
In Solr 9.x, the maxBooleanClauses limit is controlled exclusively by solr.xml. This is a server-level setting that applies to all cores on the server. It sets the Lucene-level IndexSearcher.maxClauseCount, which is the actual enforced limit.
The per-core solrconfig.xml maxBooleanClauses setting is informational only in Solr 9.x — it shows up in the config API but does NOT change the actual Lucene limit.
The Fix (Two Parts)
Part 1: JVM Properties
Add these JVM properties to your Solr startup command (e.g., in your solr.in.sh or startup script):
-Dsolr.max.booleanClauses=999999 -Dsolr.maxClauseCount=999999999 -Dsolr.max.ClauseCount=90000000000
Part 2: solr.xml
In your solr.xml, add this line inside the <solr> block:
<solr> <int name="maxBooleanClauses">${solr.max.booleanClauses:1024}</int> ... </solr>
The ${solr.max.booleanClauses:1024} syntax reads the JVM property from Part 1. If the property is not set, it falls back to 1024.
After making both changes, restart Solr (a core reload is not enough — solr.xml is only read at startup).
Critical: XML Format Matters
Solr 9.x is very specific about the XML format in solr.xml. It only recognizes the <int name="..."> format:
<!-- CORRECT — Solr 9.x reads this --> <int name="maxBooleanClauses">${solr.max.booleanClauses:1024}</int> <!-- WRONG — Solr 9.x silently ignores this --> <maxBooleanClauses>90589</maxBooleanClauses>
If you use the wrong format, Solr will not log any error — it will silently fall back to the Lucene default of 1024. This is the most common reason the setting "doesn't work."
Drupal Search API Solr — Important Warning
The Search API Solr Drupal module generates config files like solrconfig_query.xml and solrconfig_query_OK.xml with settings in this format:
<query name="maxBooleanClauses">4096</query>
Solr does not recognize this format. It is a Drupal module convention, not valid Solr configuration. Changing values in these files has no effect on the actual Solr limit.
The _OK files are internal reference files used by the module — they are not loaded by Solr and can be disregarded.
If you are using Drupal and only need site search, consider the OpenSolr Search Drupal Module — it generates much simpler queries and avoids clause explosion entirely.
On OpenSolr — Security Policy
OpenSolr does not raise the maxBooleanClauses limit by default. A higher limit allows a single malicious or poorly formed query to consume massive server resources, making it a significant denial-of-service vector — especially on shared infrastructure where multiple customers share the same Solr server.
Requests to increase this limit are subject to a security audit and are evaluated on a case-by-case basis. We generally only apply increases on dedicated or enterprise infrastructure where your index is isolated from other customers.
Additionally, Solr 10.x is removing support for overriding this limit entirely — the Lucene project considers it a necessary safety guardrail that should not be bypassed. Any workaround applied today will stop working when the server is upgraded to Solr 10.
If you are hitting this limit, the root cause is almost always the client generating unnecessarily complex queries — not a Solr misconfiguration. The correct fix is to use a client that produces efficient queries, such as the OpenSolr Search Drupal Module.
To request a limit increase for dedicated infrastructure, contact support.
Reducing Query Expansion
Even with a raised limit, reducing unnecessary clause expansion is good practice:
| Cause | Clauses Generated | Fix |
|---|---|---|
| Drupal Search API multi-field expansion | Hundreds per word | Use OpenSolr Search module instead |
Wildcard a* on large index |
Thousands | Use longer prefix or n-gram field |
| 50 synonyms per term | 50x per query word | Trim synonym list |
fq=id:(1 OR 2 OR ... OR 5000) |
5,000 | Split into batches |