我正在使用Solr 4.4作为数据存储的项目,我想升级到Solr 5.0。
问题在于,当我使用solrj发送查询以获取所有可能的结果时,查询如下:
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.addSort("sorting_score", ORDER.desc);
query.addFilterQuery("label_list:\"" + currLabel + "\"");
query.set("rows", Integer.MAX_VALUE);
(我知道这可能是错的,因为它可能会得到太多数据,但这是我的情况)
此代码在Solr 4.4中运行正常,但当我迁移到5时,会导致NegativeArraySizeException
异常,这就是错误
org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr/Event: java.lang.NegativeArraySizeException
at org.apache.lucene.util.PriorityQueue.<init>(PriorityQueue.java:56)
at org.apache.lucene.util.PriorityQueue.<init>(PriorityQueue.java:37)
at org.apache.solr.handler.component.ShardFieldSortedHitQueue.<init>(ShardDoc.java:113)
at org.apache.solr.handler.component.QueryComponent.mergeIds(QueryComponent.java:955)
at org.apache.solr.handler.component.QueryComponent.handleRegularResponses(QueryComponent.java:743)
at org.apache.solr.handler.component.QueryComponent.handleResponses(QueryComponent.java:722)
at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:350)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:144)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:2006)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:777)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:413)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:204)
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)
知道为什么会这样吗?
答案 0 :(得分:1)
如果您对所有这些数据感兴趣,则应使用此处所述的深度分页迭代:http://yonik.com/solr/paging-and-deep-paging
答案 1 :(得分:0)
从堆栈跟踪中,有一个对Filter的引用,我们可以在您的代码片段中看到Filter Query param。请尝试删除它并执行查询。您可以随时尝试查询可能正在使用curl并在您使用java之前查看。希望它有所帮助
答案 2 :(得分:0)
我知道它迟到了。这个问题是因为query.set(&#34; rows&#34;,Integer.MAX_VALUE);。