Return-Path: Delivered-To: apmail-lucene-solr-commits-archive@minotaur.apache.org Received: (qmail 87968 invoked from network); 20 Sep 2010 20:16:31 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 20 Sep 2010 20:16:31 -0000 Received: (qmail 92219 invoked by uid 500); 20 Sep 2010 20:16:31 -0000 Delivered-To: apmail-lucene-solr-commits-archive@lucene.apache.org Received: (qmail 92144 invoked by uid 500); 20 Sep 2010 20:16:30 -0000 Mailing-List: contact solr-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-dev@lucene.apache.org Delivered-To: mailing list solr-commits@lucene.apache.org Received: (qmail 92137 invoked by uid 99); 20 Sep 2010 20:16:30 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Sep 2010 20:16:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED,T_FRT_LOLITA1 X-Spam-Check-By: apache.org Received: from [140.211.11.131] (HELO eos.apache.org) (140.211.11.131) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Sep 2010 20:16:28 +0000 Received: from eosnew.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id B0CD28A0; Mon, 20 Sep 2010 20:15:58 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Apache Wiki To: Apache Wiki Date: Mon, 20 Sep 2010 20:15:58 -0000 Message-ID: <20100920201558.74999.94662@eosnew.apache.org> Subject: =?utf-8?q?=5BSolr_Wiki=5D_Update_of_=22FieldCollapsing=22_by_YonikSeeley?= X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Solr Wiki" for chan= ge 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=3Ddiff&rev1=3D18&rev2=3D= 19 -------------------------------------------------- = Now send a query request to solr and turn on result grouping. We'll firs= t 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=3Djson&indent=3Dtrue&q=3Dsolr%20me= mory&fl=3Did,name&group=3Dtrue&group.field=3Dmanu_exact]] + [[http://localhost:8983/solr/select?wt=3Djson&indent=3Dtrue&fl=3Did,name&= q=3Dsolr+memory&group=3Dtrue&group.field=3Dmanu_exact|...&q=3Dsolr+memory&g= roup=3Dtrue&group.field=3Dmanu_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 examp= le) 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 gro= up. = + We can find the top documents that also match arbitrary queries with the = {{{group.query}}} command (much like {{{facet.query}}}). For example, we co= uld use this to find the top 3 documents with in different price ranges: + = + [[http://localhost:8983/solr/select?wt=3Djson&indent=3Dtrue&fl=3Dname,pri= ce&q=3Dmemory&group=3Dtrue&group.query=3Dprice:[0+TO+99.99]&group.query=3Dp= rice:[100+TO+*]&group.limit=3D3|...&q=3Dmemory&group=3Dtrue&group.query=3Dp= rice:[0 TO 99.99]&group.query=3Dprice:[100 TO *]&group.limit=3D3]] + = + {{{ + [...] + "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 Unbuffer= ed DDR 400 (PC 3200) Dual Channel Kit System Memory - Retail", + "price":185.0}, + { + "name":"ASUS Extreme N7800GTX/2DHTV (256 MB)", + "price":479.95}] + }} + [...] + }}} + = + = <> =3D Request Parameters =3D ||'''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 b= e 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/Extern= alFileField.html|ExternalFileField]]|| ||group.func||[function query]||Group based on the unique values of a fun= ction query.|| + ||group.query||[query]||Return a single group of documents that also matc= h 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 e= xample, {{{sort=3Dpopularity desc}}} will cause the groups to be sorted by = the popularity of the highest ranking (first) document in each group. Defa= ults to "score desc".|| ||group.sort||[sortspec]||How to sort documents within a single group. D= efaults to the same value as the {{{sort}}} parameter.|| = Notes: + * Any number of group commands (group.field, group.func, group.query) ma= y be specified in a single request. * Distributed search support for result grouping has not yet been implem= ented. =20