Solr:字段中不同元素的数量
与问题相关 如何使用 Solr 选择不同的字段值? 但我想要的是计数器。
我想知道 Solr 字段中有多少个不同的元素。我可以通过使用以下方法获得这个数字:
group.field=my_field&group.ngroups=true&group.limit=0
但是为此进行分组似乎有点矫枉过正
还有其他方法吗?我必须使用 JIRA SOLR-1814 吗?
Related to question
How to select distinct field values using Solr?
but what I want is the counter.
I want to know how many distinct elements there is in a Solr field. I could get this number by using:
group.field=my_field&group.ngroups=true&group.limit=0
but doing grouping for this seems like an overkill
Is there another way ? Do I have to use JIRA SOLR-1814 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您正在寻找字段中的独特值。
您可以使用字段类型字符串对字段名称进行分面,这将返回该字段的所有唯一值(以及可能与您相关或不相关的计数)。
以下补丁@ https://issues.apache.org/jira/browse/SOLR-2242 将帮助您直接获得计数。
如果您无法使用补丁,您可能需要获取构面字段的所有值并自行计数。
If you are looking for unique values in the fields.
You can facet on the field name with the field type string, which will return all the unique values for the field (and the counts which may or may not be relevant to you).
The following patch @ https://issues.apache.org/jira/browse/SOLR-2242 will help you to get the count directly.
If you can't use the patch, you would probably need to get all the values for the facet field and count by yourself.
SOLR 3.3 及更高版本已经接受组分面,
因此如果您只是应用一个facet.query,它应该返回查询的行数。
但如果你想进行这样的查询,我不知道有任何其他方法来计算你的组数。
我怀疑是否有可能以其他方式实现。
SOLR 3.3 and newer already accept group facetting
So if you simply apply a facet.query it should return the number of rows for your query.
But I don't know of any other way to count your groups if you want to make such a query.
I doubt that is possible any other way.