1

We use a Solr 8.11.2 server. Also we use the Solr 8 web user interface to query the Solr cores.

How can I make a "distinct" (unique) query using this interface? In my example I want to know how many different values for the field "site" there are.

enter image description here

I read I can use the "Facet" option. But I only found very old posts (for Solr 4 and Solr 5), and nothing I read worked.

Can someone tell me what to input to get the distinct values for the field "site" (or any other field)?

Thanks

Klaus
  • 416
  • 4
  • 15
  • you can try below query http://localhost:8983/solr/select/?q=*%3A*&rows=0&facet=on&facet.field=site OR /select?stats=on&stats.field=site&rows=0&stats.calcdistinct=true – Abhijit Bashetti Jun 26 '23 at 19:21
  • Thanks, but this does not work. It produces an error. See post for details. – Klaus Jun 27 '23 at 05:47
  • I had given 2 alternatives not one.... the first one you can try is localhost:8983/solr/select/?q=*%3A*&rows=0&facet=on&facet.field=site – Abhijit Bashetti Jun 27 '23 at 06:42
  • The second one you can try is localhost:8983/solr/select?stats=on&stats.field=site&rows=0&stats.calcdistinct=true.. – Abhijit Bashetti Jun 27 '23 at 06:43
  • (and to add the explanation: faceting gives you all the unique values for a field and their counts, which you've probably seen as navigators as most ecommerce websites (or search engines) where you're allowed to filter/narrow your results by selecting a color/size/etc. - the value in a specific field across all documents). – MatsLindh Jun 27 '23 at 08:12
  • 1
    Thanks @AbhijitBashetti. Now I get it. The first alternative works perfectly. – Klaus Jun 27 '23 at 09:45

1 Answers1

1

The faceting option would work in this case. You can try below query

localhost:8983/solr/select/?q=*%3A*&rows=0&facet=on&facet.field=site

Faceting is the arrangement of search results into categories based on indexed terms.

Searchers are presented with the indexed terms, along with numerical counts of how many matching documents were found were each term. Faceting makes it easy for users to explore search results, narrowing in on exactly the results they are looking for

More on faceting can be found on the solr page solr faceting

Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47