Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-2242

Get distinct count of names for a facet field

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Minor
    • Resolution: Duplicate
    • 4.0-ALPHA
    • 5.2, 6.0
    • Response Writers
    • None

    Description

      When returning facet.field=<name of field> you will get a list of matches for distinct values. This is normal behavior. This patch tells you how many distinct values you have (# of rows). Use with limit=-1 and mincount=1.

      The feature is called "namedistinct". Here is an example:

      Parameters:
      facet.numTerms or f.<field>.facet.numTerms = true (default is false) - turn on distinct counting of terms

      facet.field - the field to count the terms
      It creates a new section in the facet section...

      http://localhost:8983/solr/select?shards=localhost:8983/solr,localhost:7574/solr&indent=true&q=*:*&facet=true&facet.mincount=1&facet.numTerms=true&facet.limit=-1&facet.field=price

      http://localhost:8983/solr/select?shards=localhost:8983/solr,localhost:7574/solr&indent=true&q=*:*&facet=true&facet.mincount=1&facet.numTerms=false&facet.limit=-1&facet.field=price

      http://localhost:8983/solr/select?shards=localhost:8983/solr,localhost:7574/solr&indent=true&q=*:*&facet=true&facet.mincount=1&facet.numTerms=true&facet.limit=-1&facet.field=price

      This currently only works on facet.field.

      <lst name="facet_counts">
      <lst name="facet_queries"/>
      <lst name="facet_fields">...</lst>
      <lst name="facet_numTerms">
      <lst name="localhost:8983/solr/">
      <int name="price">14</int>
      </lst>
      <lst name="localhost:8080/solr/">
      <int name="price">14</int>
      </lst>
      </lst>
      <lst name="facet_dates"/>
      <lst name="facet_ranges"/>
      </lst>
      
      OR with no sharding-
      
      <lst name="facet_numTerms">
      <int name="price">14</int>
      </lst>
      
      

      Several people use this to get the group.field count (the # of groups).

      Attachments

        1. SOLR-2242-solr40-3.patch
          6 kB
          Bill Bell
        2. SOLR-2242-3x.patch
          6 kB
          Erick Erickson
        3. SOLR-2242-3x_5_tests.patch
          18 kB
          Bill Bell
        4. SOLR-2242.solr3.1-fix.patch
          4 kB
          Nguyen Kien Trung
        5. SOLR-2242.solr3.1.patch
          4 kB
          Lance Norskog
        6. SOLR-2242.shard.withtests.patch
          13 kB
          Bill Bell
        7. SOLR-2242.patch
          4 kB
          James Dyer
        8. SOLR-2242.patch
          15 kB
          Simon Willnauer
        9. SOLR-2242.patch
          14 kB
          Erick Erickson
        10. SOLR.2242.solr3.1.patch
          4 kB
          Dmitry Drozdov

        Issue Links

          Activity

            People

              Unassigned Unassigned
              billnbell Bill Bell
              Votes:
              31 Vote for this issue
              Watchers:
              31 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: