Reputation: 672
How to return the count of a field with each object in 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. 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
}
]}
Upvotes: 1
Views: 3928
Reputation: 120
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
. For counts over all records, set q=*:*
. If you don't want to see any rows returned, you can set rows=0
.
See here for more details on faceting:
https://cwiki.apache.org/confluence/display/solr/Faceting
(I tested this with Solr 5, but faceting should work with Solr 4 as well.)
Upvotes: 1