Solr:字段中不同元素的数量

发布于 2024-12-05 00:17:32 字数 455 浏览 0 评论 0原文

与问题相关 如何使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

帝王念 2024-12-12 00:17:32

如果您正在寻找字段中的独特值。
您可以使用字段类型字符串对字段名称进行分面,这将返回该字段的所有唯一值(以及可能与您相关或不相关的计数)。

以下补丁@ 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.

彼岸花ソ最美的依靠 2024-12-12 00:17:32

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文