The Error
Your search query fails with this exception:
org.apache.solr.common.SolrException: Too many boolean clauses (1025).
This means Solr tried to run a query that expanded into more than 1,024 individual conditions, and hit the safety limit.
What Is Actually Happening
Every search query that Solr processes gets broken down into boolean clauses — individual yes/no conditions that Solr checks against every document. A simple query like q=hello is just 1 clause. But some queries expand into hundreds or thousands of clauses behind the scenes.
Common Causes
1. Synonym Explosion
If your synonyms.txt maps each word to many alternatives, a simple 5-word query can explode into hundreds of clauses. Each synonym adds a new clause for every term.
2. Wildcard Queries
Queries like *term (leading wildcard) or very short prefix queries like a* match thousands of terms in the index. Each matched term becomes a clause.
3. Massive Filter Lists
Sending a filter query with hundreds of values like fq=id:(1 OR 2 OR 3 OR ... OR 2000) creates one clause per value.
How to Fix It
Solution 1: Increase the Limit (Quick Fix)
Important (July 2024 update): The maxBooleanClauses setting has moved to solr.xml (not solrconfig.xml).
Contact Opensolr Support to increase this limit for your Opensolr Index. The setting lives in solr.xml:
<solr> <int name="maxBooleanClauses">90589</int> </solr>
Since solr.xml is a server-level config, you will need to contact support to change it.
Solution 2: Reduce Query Expansion (Root Cause Fix)
- Trim your synonyms.txt — remove rarely used synonyms that expand queries unnecessarily
- Avoid leading wildcards — use
term*(prefix) instead of*term(leading wildcard). If you need substring matching, use an n-gram tokenizer instead - Split large filter lists — break
fq=id:(val1 OR val2 OR ... OR val2000)into multiple smaller queries and combine results in your application
Solution 3: Optimize Your Analyzer Chain
- Apply synonyms at query time using
SynonymGraphFilterFactory, not at index time — this gives you more control - Place stopword filters before synonym filters — removing common words first means fewer terms for the synonym filter to expand
- Use
edgeNgramtokenizers for partial matching instead of wildcard queries
Quick Reference
| Cause | Clauses Generated | Fix |
|---|---|---|
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 |
| Complex nested boolean query | Varies | Simplify or restructure |
Quick Checklist
- Check your synonyms.txt — are there terms with dozens of synonyms?
- Check for wildcard queries — especially leading wildcards (
*term) - Check for large OR lists in filter queries
- Ask Opensolr Support to increase
maxBooleanClausesinsolr.xmlif needed - Consider using n-gram fields instead of wildcard queries for partial matching
Need your boolean clause limit increased? Reach out to us at support@opensolr.com — we can adjust it for your Opensolr Index in minutes.