Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 32843 invoked from network); 2 Sep 2009 11:51:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Sep 2009 11:51:41 -0000 Received: (qmail 7700 invoked by uid 500); 2 Sep 2009 11:51:39 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 7627 invoked by uid 500); 2 Sep 2009 11:51:39 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 7617 invoked by uid 99); 2 Sep 2009 11:51:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2009 11:51:39 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of serera@gmail.com designates 74.125.78.25 as permitted sender) Received: from [74.125.78.25] (HELO ey-out-2122.google.com) (74.125.78.25) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2009 11:51:29 +0000 Received: by ey-out-2122.google.com with SMTP id 4so677891eyf.5 for ; Wed, 02 Sep 2009 04:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=MwzZsROkxVB5RIbLLkj1AwCq513muJwWXNha4KZa288=; b=qWk2ytK/UVxDHPwYTR3mP3+XOWvzgjj6mbA2ynxadrw7zDz7DZl007NzLwxGTNQ49L xD7S7FmtTmjxhnLWKwvnGi0An4i30kaQ6LCmIOHP1Ha8RLJeceXm0E/nouVEF75qJpBG b7VCKUi2d+TLbsYYpBNHJKYZQYZA2icCSLuok= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=tXXGeRHyJccXdTzDppDVnktVV0N8DavhMvAIkQOkY/8zF0bJ5aCEas3hotMUPiO5Ag MPxwjZ7Hb/XiBebvgc/pEOL/7t7gSLGjSATHCAu8ynsy4NnMA1Ozy+WSqFNTCC9NxsnV syw3TYwVO3OiY56vEQOehZ79JbvnWoOaLHW28= MIME-Version: 1.0 Received: by 10.216.52.204 with SMTP id e54mr131854wec.171.1251892269293; Wed, 02 Sep 2009 04:51:09 -0700 (PDT) In-Reply-To: <004101ca2bc1$eab54070$710bc30a@sv.us.sonicwall.com> References: <003101ca2bb9$419a0f00$710bc30a@sv.us.sonicwall.com> <786fde50909020403n3f2d72d8gc35a0d7bc6d21c62@mail.gmail.com> <004101ca2bc1$eab54070$710bc30a@sv.us.sonicwall.com> Date: Wed, 2 Sep 2009 14:51:09 +0300 Message-ID: <786fde50909020451p3ef98563s40f94a595c059087@mail.gmail.com> Subject: Re: First result in the group From: Shai Erera To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=0016e6dbe74c022190047296e21e X-Virus-Checked: Checked by ClamAV on apache.org --0016e6dbe74c022190047296e21e Content-Type: text/plain; charset=ISO-8859-1 I see ... the solution I have in mind is not simple, but it follows the Collector approach. Index categories as payloads of documents such that there is one field (cats:all for example) that includes a posting list for all documents, each has the categories it is associated w/ in its payload: cats:all --> 0 [cat1, cat2] 1 [cat1, cat3, cat4] 4 [cat2, cat3, cat4] ... Then when Collector.collect() is called, skip to that doc ID and read its categories and store the ID in category maps (i.e., you'll have maps for cat1, cat2, ... catN, each will include all doc IDs, sorted by score, which were collected by this query). Then you can fetch all categories whose maps/sets are not empty and display M docs from each. If you know in advance which categories are requested to be grouped by, for example I want a group by on categories 1, 3, 4 and 7, you can optimize the solution further, but I'm not sure if that's what you requested. Also, if you can translate category Strings to integers, you can store more efficient payloads ... Shai On Wed, Sep 2, 2009 at 2:38 PM, Ganesh wrote: > I have a field called category and all documents will have belong to some > category( say some belong to X and some Y etc). The field values may change > dynamically. I want the search results to be filterted to retrieve one > document per category. > > This is similar to 'group by' feature in database. > > Regards > Ganesh > > > ----- Original Message ----- > From: "Shai Erera" > To: > Sent: Wednesday, September 02, 2009 4:33 PM > Subject: Re: First result in the group > > > > What do you mean by "first result in the group"? What is a group? > > > > On Wed, Sep 2, 2009 at 1:36 PM, Ganesh wrote: > > > >> Hello all, > >> > >> I want to retrieve the first result in the group. How to acheive this? > >> Currently i am parsing all the results, using a hash and avoiding > duplicate > >> entries. > >> > >> Is there any better way? > >> > >> Regards > >> Ganesh > >> Send instant messages to your online friends > http://in.messenger.yahoo.com > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > >> For additional commands, e-mail: java-user-help@lucene.apache.org > >> > >> > > > Send instant messages to your online friends http://in.messenger.yahoo.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > --0016e6dbe74c022190047296e21e--