基于所有索引值的Solr分组 [英] solr grouping based on all index values

查看:135
本文介绍了基于所有索引值的Solr分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我基于字段对Solr进行分组或构面时,我只会收到搜索结果中包含的文档数.有没有一种方法可以对整个索引中包含该值的文档进行计数? 例如,使用此数据,我想搜索某物",并且每个唯一的gs字段仅取回一项,其中包含索引中所有字段的计数.因此,按照gs 50005的分组,id 2就会出现,但是计数将是2而不是1.

When I group or facet in solr based on a field, I only receive a count of documents that are in the search results. Is there a way to get a count of the documents that contain that value across the entire index? For example, with this data, I would like to search for "something" and get back only one item per unique gs field with a count of all the fields in the index. So id 2 would come up, as grouped by gs 50005, but the count would be 2 instead of 1.

<doc>
<field name="id">1</field>
<field name="gs">50005</field>
<field name="text">blah</field>
</doc>

<doc>
<field name="id">2</field>
<field name="gs">50005</field>
<field name="text">something else</field>
</doc>

<doc>
<field name="id">3</field>
<field name="gs">123</field>
<field name="text">another something value</field>
</doc>

<doc>
<field name="id">4</field>
<field name="gs">5423</field>
<field name="text">something entirely different</field>
</doc>

推荐答案

我有一个解决方法: {!join from = gs to = gs} gs:field(gs)text:something& group = true& group.field = gs

I have a work around: {!join from=gs to=gs}gs:field(gs) text:something&group=true&group.field=gs

从本质上讲,此工作方式是通过联接将查询扩展为包括具有相同gs的​​所有项目,然后将其按gs分组.通过分组,我在XML中获得了该组中有多少个项目的值.

Essentially, the way this works is the query is expanded through a join to include all items that have that same gs and then it is grouped by gs. Through grouping I have a value in XML of how many items are in the group.

不是很优雅,但是应该可以解决问题.

Not very elegant, but should do the trick.

这篇关于基于所有索引值的Solr分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆