Exception as Org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to XXXX

StackOverflow https://stackoverflow.com/questions/19677214

  •  01-07-2022
  •  | 
  •  

Question

I'm getting exception like below -

ERROR [http-bio-8085-exec-28] org.apache.solr.core.SolrCore - org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024 at org.apache.lucene.search.BooleanQuery.add(BooleanQuery.java:136) at org.apache.lucene.search.BooleanQuery.add(BooleanQuery.java:127) at org.apache.lucene.search.ScoringRewrite$1.addClause(ScoringRewrite.java:51) at org.apache.lucene.search.ScoringRewrite$1.addClause(ScoringRewrite.java:55)

As per my understanding, This exception comes at QueryTime (when query clauses crosses it's limit here in this case 1024) but can this come at Indexing time ?

I've got this in logs, and not sure which process (indexing / Querying) this is occurring in ?

Thanks. Dev

Was it helpful?

Solution

Generally, there is no query involved in indexing new data, so you shouldn't see this when adding a document.

However, when updating or deleting documents, they may be retrieved with a query (using deleteDocuments(Query query), for example). It would be unusual for a deletion or update query to be complex enough to generate 1024 clauses, but it could happen.

Much more likely that it is the result of a search query, though.

OTHER TIPS

I've also encountered this error when using Lucene BooleanQuery. I get the following exception:

org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024.

The reason is that the query term is beyond the BooleanQuery limits. You can solve this using BooleanQuery.setMaxClauseCount(10000);. However, you should be careful as this may cause an OutOfMemory error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top