[英]count based on a specific field in SOLR
How to return the count of a field with each object in Solr 如何在Solr中使用每个对象返回字段的计数
When I do fq=verify_ix:1
I have a response below, I want to get count where verify_ix = 1 in the response too. 当我执行
fq=verify_ix:1
我在下面有一个响应,我也想在响应中verify_ix = 1的情况下获得计数。 How can I do that? 我怎样才能做到这一点?
"response": {
"numFound": 9484,
"start": 0,
"maxScore": 1,
"docs": [
{
"id": "10000000000965509",
"description_s": "No Description",
"recommendation_ix": 0,
"sId_lx": 30005938,
"sType_sx": "P",
"condition_ix": 1000,
"verify_ix": 1
},
.
.
.
{
"id": "10000000000965734",
"description_s": "No Description",
"recommendation_ix": 1,
"sId_lx": 30005947,
"sType_sx": "P",
"condition_ix": 2000,
"verify_ix": 1
}
]}
If you want counts of the different values for a given field, you can send a request to Solr with facet=true
and facet.field=verify_ix
. 如果要计算给定字段的不同值,则可以使用
facet=true
和facet.field=verify_ix
向Solr发送请求。 For counts over all records, set q=*:*
. 对于所有记录的计数,请设置
q=*:*
。 If you don't want to see any rows returned, you can set rows=0
. 如果您不想看到任何返回的行,可以将
rows=0
设置。
See here for more details on faceting: 请参阅此处以获取有关构面的更多详细信息:
https://cwiki.apache.org/confluence/display/solr/Faceting https://cwiki.apache.org/confluence/display/solr/Faceting
(I tested this with Solr 5, but faceting should work with Solr 4 as well.) (我在Solr 5上对此进行了测试,但分面也应在Solr 4上使用。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.