3

I want to the sum of count of unique values of a field in solr.

My original requirement is like this: I have a collection in solr cloud, spread across multiple shards from which I have to get the list of unique values of the field(let's say abc), which has duplicate values. And the sorting of the search results should be such that the value having the maximum occurance should be at the top and least occurance should be at the bottom.

I have been able to achieve this requirement by the below query and it works totally fine.

http://localhost:8983/solr/secondcol/select?q=test&wt=json&indent=true&facet=true&facet.field=abc&facet.mincount=1&rows=0&facet.offset=0&facet.limit=10

But I am not able to get the count of the total num of facets returned here. Is there a way to do it.

I am doing this in solr 4.10 and 5.3

Aᴍɪʀ
  • 7,623
  • 3
  • 38
  • 52
user2821080
  • 25
  • 1
  • 3

1 Answers1

2

You could specify facet.limit=-1 and count the number of terms returned.

In Solr 5.3 there is JSON facets which has the parameter numBucketsthat seems to do what you want, but I do not know if that works properly in SolrCloud.

Toke Eskildsen
  • 709
  • 4
  • 10