solr distinct query I want only certain fields to be listed

57 views Asked by At

I want to find the number of unique records based on myparam value.

Solr distinct query I want only certain fields to be listed. too many ifs in the distinctValues ​​array in the results. whereas I just want to get the countDistinct value.

url: http://xxxxxxx:18282/solr/2022/select?q=:&wt=json&rows=0&stats=on&stats.calcdistinct=true&stats.field=myparam

In fact, it would be great if I could get a result like the one below. result:

{
  "responseHeader":{
    "status":0,
    "QTime":10627,
    "params":{
      "q":"*:*",
      "stats.calcdistinct":"true",
      "stats":"on",
      "rows":"0",
      "wt":"json",
      "stats.field":"myparam"}},
  "response":{"numFound":816091,"start":0,"docs":[]
  },
  "stats":{
    "stats_fields":{
      "myparam":{
        "countDistinct":5,
 }}}}
1

There are 1 answers

0
mustafa On BEST ANSWER

I found the answer I was looking for in solr functions. adress:18282/solr/2021/select?q=:&wt=json&json.facet={x:'unique(username)'}&rows=0 Accordingly, I can find out how many different users there are.