Skip to content

Solr Hero Product Too Many Boolean Clause Error

Hybris 5.x Hero Product issue. Hero Product is deprecated over 6.x version. Newer versions have Adaptive Search instead of Hero Product.

Problem

Business users use HeroProduct to boost some promotional products for sale. They bound more than 1000 products to 1 HeroProductDefinition and as a result we faced too many boolean clause error on Solr. Plp (product list page) did not display any result for the query.

I found two solutions to solve this error:

  1. Warn business users to not add more than 1000 products for 1 HeroProductDefinition
  2. Increase boolean clause limit on Solr

I applied second solution.

Error

org.apache.solr.common.SolrException: org.apache.solr.search.SyntaxError: Cannot parse
too many boolean clauses
org.apache.solr.common.SolrException: org.apache.solr.search.SyntaxError: Cannot parse '(pk:(8948717518849^7747999.0 OR 8921851297793^9485999.0 OR 8947813416961^9955999.0 OR 8944953229313^7377999.0 OR 8948017266689^8063999.0 OR 8948015792129^7397999.0 OR 8944341024769^7591999.0 OR 8921402081281^7425999.0 OR 8945365286913^7861999.0 OR 8944157786113^7433999.0 OR 8942686535681^9247999.0 OR 8937018425345^7879999.0 OR
...
too many boolean clauses
	at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:171)
	at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:187)
	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
	at org.apache.solr.core.SolrCore.execute(SolrCore.java:1859)
	at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:721)
	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:417)
	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:201)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
	at org.eclipse.jetty.server.Server.handle(Server.java:368)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
	at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1004)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
	at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
	at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
	at java.lang.Thread.run(Thread.java:745)

too many boolean clauses
	at org.apache.solr.parser.SolrQueryParserBase.parse(SolrQueryParserBase.java:163)
	at org.apache.solr.search.LuceneQParser.parse(LuceneQParser.java:50)
	at org.apache.solr.search.QParser.getQuery(QParser.java:142)
	at org.apache.solr.search.ExtendedDismaxQParser.getBoostQueries(ExtendedDismaxQParser.java:457)
	at org.apache.solr.search.ExtendedDismaxQParser.parse(ExtendedDismaxQParser.java:169)
	at org.apache.solr.search.QParser.getQuery(QParser.java:142)
	at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:142)
	... 31 more
Caused by: org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024
	at org.apache.lucene.search.BooleanQuery.add(BooleanQuery.java:142)
	at org.apache.solr.parser.SolrQueryParserBase.getBooleanQuery(SolrQueryParserBase.java:513)
	at org.apache.solr.parser.SolrQueryParserBase.getBooleanQuery(SolrQueryParserBase.java:489)
	at org.apache.solr.parser.QueryParser.Query(QueryParser.java:146)
	at org.apache.solr.parser.QueryParser.Clause(QueryParser.java:190)
	at org.apache.solr.parser.QueryParser.Query(QueryParser.java:108)
	at org.apache.solr.parser.QueryParser.Clause(QueryParser.java:190)
	at org.apache.solr.parser.QueryParser.Query(QueryParser.java:108)
	at org.apache.solr.parser.QueryParser.TopLevelQuery(QueryParser.java:97)
	at org.apache.solr.parser.SolrQueryParserBase.parse(SolrQueryParserBase.java:153)

Solution

Steps:

  1. Edit solrconfig.xml
  2. Restart Solr Server to apply config change
  3. Check config

Apply these steps by starting slave nodes. After changing all slaves, apply steps to master node.

1. Edit solrconfig.xml

Open solrconfig.xml

nano /solr/server/conf/solrconfig.xml

Default maxBooleanClauses value is 1024

Replace default 1024 with any higher value. I set it to 4096 and it fixed my issue. I may increase it later, if same error occurs again.

Replace line

<maxBooleanClauses>1024</maxBooleanClauses>

with

<maxBooleanClauses>4096</maxBooleanClauses>

Save and exit.

2. Restart Solr Server

Official document says /bin/solr stop and /bin/solr start commands are enough to apply config changes.I had chance to restart servers, so I did it.

3. Check config

After restarting check Solr Dashboard to see config change.

solr config maxBooleanClauses

Leave a Reply

Your email address will not be published. Required fields are marked *