[ 
https://issues.apache.org/jira/browse/SOLR-2242?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13006805#comment-13006805
 ] 

Bill Bell edited comment on SOLR-2242 at 3/15/11 6:10 AM:
----------------------------------------------------------

OK this is complete.

Sample query:

http://localhost:8983/solr/select?q=*:*&facet=true&facet.field=cat&rows=0&facet.numfacetterms=2&facet.limit=4

Sample output:
{code}
  <?xml version="1.0" encoding="UTF-8" ?> 
- <response>
- <lst name="responseHeader">
  <int name="status">0</int> 
  <int name="QTime">0</int> 
- <lst name="params">
  <str name="facet.numfacetterms">2</str> 
  <str name="facet">true</str> 
  <str name="q">*:*</str> 
  <str name="facet.limit">4</str> 
  <str name="facet.field">cat</str> 
  <str name="rows">0</str> 
  </lst>
  </lst>
  <result name="response" numFound="17" start="0" /> 
- <lst name="facet_counts">
  <lst name="facet_queries" /> 
- <lst name="facet_fields">
- <lst name="cat">
  <int name="numFacetTerms">14</int> 
- <lst name="counts">
  <int name="electronics">14</int> 
  <int name="memory">3</int> 
  <int name="connector">2</int> 
  <int name="graphics card">2</int> 
  </lst>
  </lst>
  </lst>
  <lst name="facet_dates" /> 
  <lst name="facet_ranges" /> 
  </lst>
  </response>
{code}

In Json:

{code}
"facet_fields":{"cat":["numFacetTerms",14,"counts",["electronics",14,"memory",3,"connector",2,"graphics
 card",2]]},"facet_dates":{},"facet_ranges":{}}}
{code}

      was (Author: billnbell):
    OK this is complete.

Sample query:

http://localhost:8983/solr/select?q=*:*&facet=true&facet.field=cat&rows=0&facet.numfacetterms=2&facet.limit=4

Sample output:
{code}
  <?xml version="1.0" encoding="UTF-8" ?> 
- <response>
- <lst name="responseHeader">
  <int name="status">0</int> 
  <int name="QTime">0</int> 
- <lst name="params">
  <str name="facet.numfacetterms">2</str> 
  <str name="facet">true</str> 
  <str name="q">*:*</str> 
  <str name="facet.limit">4</str> 
  <str name="facet.field">cat</str> 
  <str name="rows">0</str> 
  </lst>
  </lst>
  <result name="response" numFound="17" start="0" /> 
- <lst name="facet_counts">
  <lst name="facet_queries" /> 
- <lst name="facet_fields">
- <lst name="cat">
  <int name="numFacetTerms">14</int> 
- <lst name="counts">
  <int name="electronics">14</int> 
  <int name="memory">3</int> 
  <int name="connector">2</int> 
  <int name="graphics card">2</int> 
  </lst>
  </lst>
  </lst>
  <lst name="facet_dates" /> 
  <lst name="facet_ranges" /> 
  </lst>
  </response>
{code}

In Json:

{code}
{"responseHeader":{"status":0,"QTime":0,"params":{"facet.numfacetterms":"2","facet":"true","q":"*:*","facet.limit":"4","facet.field":"cat","wt":"json","rows":"0"}},"response":{"numFound":17,"start":0,"docs":[]},"facet_counts":{"facet_queries":{},"facet_fields":{"cat":["numFacetTerms",14,"counts",["electronics",14,"memory",3,"connector",2,"graphics
 card",2]]},"facet_dates":{},"facet_ranges":{}}}

{code}
  
> Get distinct count of names for a facet field
> ---------------------------------------------
>
>                 Key: SOLR-2242
>                 URL: https://issues.apache.org/jira/browse/SOLR-2242
>             Project: Solr
>          Issue Type: New Feature
>          Components: Response Writers
>    Affects Versions: 4.0
>            Reporter: Bill Bell
>            Priority: Minor
>             Fix For: 4.0
>
>         Attachments: SOLR-2242-distinctFacet.patch, SOLR-2242.v2.patch
>
>
> 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:
> http://localhost:8983/solr/select?q=*:*&facet=true&facet.field=manu&facet.mincount=1&facet.limit=-1&f.manu.facet.namedistinct=0&facet.field=price&f.price.facet.namedistinct=1
> Here is an example on field "hgid" (without namedistinct):
> {code}
> - <lst name="facet_fields">
> - <lst name="hgid">
>   <int name="HGPY0000045FD36D4000A">1</int> 
>   <int name="HGPY00000FBC6690453A9">1</int> 
>   <int name="HGPY00001E44ED6C4FB3B">1</int> 
>   <int name="HGPY00001FA631034A1B8">1</int> 
>   <int name="HGPY00003317ABAC43B48">1</int> 
>   <int name="HGPY00003A17B2294CB5A">5</int> 
>   <int name="HGPY00003ADD2B3D48C39">1</int> 
>   </lst>
>   </lst>
> {code}
> With namedistinct (HGPY0000045FD36D4000A, HGPY00000FBC6690453A9, 
> HGPY00001E44ED6C4FB3B, HGPY00001FA631034A1B8, HGPY00003317ABAC43B48, 
> HGPY00003A17B2294CB5A, HGPY00003ADD2B3D48C39). This returns number of rows 
> (7), not the number of values (11).
> {code}
> - <lst name="facet_fields">
> - <lst name="hgid">
>   <int name="_count_">7</int> 
>   </lst>
>   </lst>
> {code}
> This works actually really good to get total number of fields for a 
> group.field=hgid. Enjoy!

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to