我通过结果集中的TopicID字段对搜索结果进行分组。
但是当我这样做时,Facet计数正在使用该Facet的匹配总数而不是对它们进行分组。是否可以显示组的总数而不是匹配的文档?
我尝试将group.facet设置为true,但是当我这样做时,我没有得到任何结果,我收到错误。
这是我的查询设置
http://localhost:8983/solr/topics/select?defType=edismax&group.field=topic_id&group=true&q=Lens&qf=topic_id%20topic_title%20post_text%20userNameSearch^5&rows=2
这将返回3,066组中的10,770份文件
在我的userName Facet上我有 用户名1(10,840) 用户名2(374) ....
当我在用户名1上过滤时,我会得到575个包含10,840个文档的组。
我试图在Facet上显示正确的组数而不是总文档数。
当我添加group.facet=true
时,我收到以下错误消息
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","java.lang.IllegalStateException"],
"msg":"Exception during facet.field: userName",
"trace":"org.apache.solr.common.SolrException: Exception during facet.field: userName\r\n\tat org.apache.solr.request.SimpleFacets.lambda$getFacetFieldCounts$0(SimpleFacets.java:840)\r\n\tat java.util.concurrent.FutureTask.run(Unknown Source)\r\n\tat org.apache.solr.request.SimpleFacets$3.execute(SimpleFacets.java:773)\r\n\tat org.apache.solr.request.SimpleFacets.getFacetFieldCounts(SimpleFacets.java:849)\r\n\tat org.apache.solr.handler.component.FacetComponent.getFacetCounts(FacetComponent.java:329)\r\n\tat org.apache.solr.handler.component.FacetComponent.process(FacetComponent.java:273)\r\n\tat org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:295)\r\n\tat org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:195)\r\n\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:2503)\r\n\tat org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:711)\r\n\tat org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:517)\r\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:384)\r\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:330)\r\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1629)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)\r\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)\r\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\r\n\tat org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:219)\r\n\tat org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)\r\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)\r\n\tat org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:335)\r\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)\r\n\tat org.eclipse.jetty.server.Server.handle(Server.java:530)\r\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:347)\r\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:256)\r\n\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)\r\n\tat org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)\r\n\tat org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)\r\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:247)\r\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)\r\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)\r\n\tat org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:382)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:708)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:626)\r\n\tat java.lang.Thread.run(Unknown Source)\r\nCaused by: java.lang.IllegalStateException: unexpected docvalues type NUMERIC for field 'topic_id' (expected=SORTED). Re-index with correct docvalues type.\r\n\tat org.apache.lucene.index.DocValues.checkField(DocValues.java:340)\r\n\tat org.apache.lucene.index.DocValues.getSorted(DocValues.java:392)\r\n\tat org.apache.lucene.search.grouping.TermGroupFacetCollector$SV.doSetNextReader(TermGroupFacetCollector.java:146)\r\n\tat org.apache.lucene.search.SimpleCollector.getLeafCollector(SimpleCollector.java:33)\r\n\tat org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:651)\r\n\tat org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:462)\r\n\tat org.apache.solr.request.SimpleFacets.getGroupedCounts(SimpleFacets.java:723)\r\n\tat org.apache.solr.request.SimpleFacets.getTermCounts(SimpleFacets.java:497)\r\n\tat org.apache.solr.request.SimpleFacets.getTermCounts(SimpleFacets.java:426)\r\n\tat org.apache.solr.request.SimpleFacets.lambda$getFacetFieldCounts$0(SimpleFacets.java:834)\r\n\t... 45 more\r\n",
"code":500}}
答案 0 :(得分:-1)
每当您为特定字段的组传递查询时,它将返回文档匹配计数的总数。
但是如果你想获得响应中的组总数以及文档匹配,请通过额外的参数。
&group.ngroups=true
如果您在当时传递了上述参数,则还会获得响应中的组计数。
http://localhost:8983/solr/topics/select?defType=edismax&group.field=topic_id&group=true&q=Lens&qf=topic_id%20topic_title%20post_text%20userNameSearch^5&rows=2&group.ngroups=true
你将得到以下重新开始,
grouped: {
ssub_chain: {
matches: 4,
ngroups: 4,
groups: [
{
groupValue: "Momo Junction_10869",
doclist: {},
},
{..},
{..},
{..},
],
}
},