lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Solr Wiki] Update of "FieldCollapsing" by YonikSeeley
Date Mon, 20 Sep 2010 20:15:58 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "FieldCollapsing" page has been changed by YonikSeeley.
The comment on this change is: document group.query.
http://wiki.apache.org/solr/FieldCollapsing?action=diff&rev1=18&rev2=19

--------------------------------------------------

  
  Now send a query request to solr and turn on result grouping.  We'll first try grouping
on the manufacturer name (the manu_exact field). <!> You can currently only group on
single-valued fields!
  
- [[http://localhost:8983/solr/select?wt=json&indent=true&q=solr%20memory&fl=id,name&group=true&group.field=manu_exact]]
+ [[http://localhost:8983/solr/select?wt=json&indent=true&fl=id,name&q=solr+memory&group=true&group.field=manu_exact|...&q=solr+memory&group=true&group.field=manu_exact]]
  
  And the grouped response is returned:
  
@@ -53, +53 @@

  The response indicates that there are 9 total matches to our query.
  For each unique value of collapse.field (manufacturer names in this example) a docList with
the top scoring document is returned.  The docList also gives the total number of matches
in that group as "numFound".  The groups themselves are also sorted by the score of the top
document within each group.
  
+ We can find the top documents that also match arbitrary queries with the {{{group.query}}}
command (much like {{{facet.query}}}). For example, we could use this to find the top 3 documents
with in different price ranges:
+ 
+ [[http://localhost:8983/solr/select?wt=json&indent=true&fl=name,price&q=memory&group=true&group.query=price:[0+TO+99.99]&group.query=price:[100+TO+*]&group.limit=3|...&q=memory&group=true&group.query=price:[0
TO 99.99]&group.query=price:[100 TO *]&group.limit=3]]
+ 
+ {{{
+ [...]
+   "grouped":{
+     "price:[0 TO 99.99]":{
+       "matches":5,
+       "doclist":{"numFound":1,"start":0,"docs":[
+           {
+             "name":"CORSAIR ValueSelect 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200)
System Memory - Retail",
+             "price":74.99}]
+       }},
+     "price:[100 TO *]":{
+       "matches":5,
+       "doclist":{"numFound":3,"start":0,"docs":[
+           {
+             "name":"Canon PIXMA MP500 All-In-One Photo Printer",
+             "price":179.99},
+           {
+             "name":"CORSAIR  XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM Unbuffered DDR 400 (PC
3200) Dual Channel Kit System Memory - Retail",
+             "price":185.0},
+           {
+             "name":"ASUS Extreme N7800GTX/2DHTV (256 MB)",
+             "price":479.95}]
+       }}
+ [...]
+ }}}
+ 
+ 
  <<Anchor(parameters)>>
  = Request Parameters =
  ||'''param name''' ||'''param value'''||'''description''' ||
  ||group||true/false||if true, turn on result grouping||
  ||group.field||[fieldname]||Group based on the unique values of a field.  The field must
currently be single-valued and must be either indexed, or be another field type that has a
value source and works in a function query - such as [[http://lucene.apache.org/solr/api/org/apache/solr/schema/ExternalFileField.html|ExternalFileField]]||
  ||group.func||[function query]||Group based on the unique values of a function query.||
+ ||group.query||[query]||Return a single group of documents that also match the given query.||
  ||rows||[number]||The number of groups to return. Defaults to 10.||
  ||group.limit||[number]||The number of results (documents) to return for each group.  Defaults
to 1.||
  ||sort||[sortspec]||How to sort the groups relative to each other.  For example, {{{sort=popularity
desc}}} will cause the groups to be sorted by the popularity of the highest ranking (first)
document in each group.  Defaults to "score desc".||
  ||group.sort||[sortspec]||How to sort documents within a single group.  Defaults to the
same value as the {{{sort}}} parameter.||
  
  Notes:
+  * Any number of group commands (group.field, group.func, group.query) may be specified
in a single request.
   * Distributed search support for result grouping has not yet been implemented.
  

Mime
View raw message