My company has a search application that we are trying to migrate to solrcloud. One of the key queries that we execute uses the field collapsing capability (grouping). We are using Solr 4.10.4 We set up a two node cloud where I created several collections each with two shards they all use the default compositeId router.
We group on a string field s_id. I created a new unique field in the schema, shard_spec which is created from concatenating the s_id field with the old unique field. An example of the field: trizmabase1211477861!T1503SIGMA
The same query runs perfectly on a non-solr core. On solr cloud I get:
java.lang.IllegalArgumentException: numHits must be > 0; please use TotalHitCountCollector if you just need the total hit count
at org.apache.lucene.search.TopFieldCollector.create(TopFieldCollector.java:1130)
at org.apache.lucene.search.TopFieldCollector.create(TopFieldCollector.java:1079)
at org.apache.lucene.search.grouping.AbstractSecondPassGroupingCollector.<init>(AbstractSecondPassGroupingCollector.java:75)
at org.apache.lucene.search.grouping.term.TermSecondPassGroupingCollector.<init>(TermSecondPassGroupingCollector.java:49)
at org.apache.solr.search.grouping.distributed.command.TopGroupsFieldCommand.create(TopGroupsFieldCommand.java:129)
at org.apache.solr.search.grouping.CommandHandler.execute(CommandHandler.java:142)
at org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:412)
at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:218)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1976)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:777)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:418)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:207)
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.content(AbstractHttpConnection.java:953)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1014)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
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)
I tried to simplify the query to be :. All group queries fail with this error. They fail in every cloud collection I've tried. Is 4.10.4 broken for grouping in Solrcloud? This will likely prevent us from going to Solrcloud
I do see a Solr Jira that looks similar to this SOLR-4164. The comments there indicated that it was hard to reproduce, I can't get it to not happen!
The group portion of the query is: group=true&group.field=s_id&group.limit=-1&group.sort=ds%20asc I have found that changing group.limit to a 500 enables the query to run. 500 is our maximum for business reasons
Turns out that setting the group.limit flag to -1 was the cause of the problem. I believe that we wanted all matching documents to be returned. However, for business reasons we limit the number to 500. I guess that there is a bug in solr, but the workaround should suffice.