From java-user-return-53083-apmail-lucene-java-user-archive=lucene.apache.org@lucene.apache.org Wed Jun 27 09:12:42 2012 Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D589FCBC1 for ; Wed, 27 Jun 2012 09:12:42 +0000 (UTC) Received: (qmail 40667 invoked by uid 500); 27 Jun 2012 09:12:40 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 40582 invoked by uid 500); 27 Jun 2012 09:12:40 -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 40569 invoked by uid 99); 27 Jun 2012 09:12:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Jun 2012 09:12:40 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ian.lea@gmail.com designates 209.85.213.176 as permitted sender) Received: from [209.85.213.176] (HELO mail-yx0-f176.google.com) (209.85.213.176) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Jun 2012 09:12:35 +0000 Received: by yenl5 with SMTP id l5so809602yen.35 for ; Wed, 27 Jun 2012 02:12:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=AAcogkMZ+QuKK6JP8NODx14C4xfQ9zB3TRBJM48gzho=; b=e9Q+U9vuqLvEpqpMP4cP+/KYLHOwsO5rFz/KcGTcyNQGBUOhowP2WH73uV7sr5/QDJ kJIXEx3heFR66onjc98aRoUBBpgm3jJmqPC2r2S04R//QXtR3dND+wE87t5vzc5+9Mt8 fnPRyzFDS2zpDFoQQSBtGByewZFl1Gm8lRbS5haD487hoDRvvlvdjw/RzW054aU7S485 pO0+n1SersEYBvecHg9rP8ACC4BuoTyfhiQwMjZmrsE/XZoZihBh3CUzvNlipXw8Zpuk ztSMHU5+KM5PonMpswdczklAGC9HFXEDRhyVkRGQtwOkHdUpQnpXkIECNKUQqUpvpora p2Ag== Received: by 10.50.197.168 with SMTP id iv8mr658612igc.12.1340788334419; Wed, 27 Jun 2012 02:12:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.96.138 with HTTP; Wed, 27 Jun 2012 02:11:54 -0700 (PDT) In-Reply-To: References: From: Ian Lea Date: Wed, 27 Jun 2012 10:11:54 +0100 Message-ID: Subject: Re: Lucene Query About Sorting To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org I think he wants 1, sort all matched docs by field A. If lucene sorting doesn't work for you you can always sort the hits yourself using whatever technique you want. Sorting large numbers of docs is always going to be expensive. -- Ian. On Wed, Jun 27, 2012 at 8:54 AM, Li Li wrote: > what do you want to do? > 1. sort all matched docs by field A. > 2. sort all matched docs by relevant score, selecting top 100 docs and > then sort by field A > > > On Wed, Jun 27, 2012 at 1:44 PM, Yogesh patel > wrote: >> Thanks for reply Ian , >> >> But i just gave suppose document number..i have 2-3 GB index and every d= ay >> , it goes higher. so i cant use searcher.maxdoc(). So i need this soluti= on. >> Can you please help me out? >> >> >> On Tue, Jun 26, 2012 at 10:42 PM, Ian Lea wrote: >> >>> Do you mean you want all hits that match B:abc, sorted by field A? =A0A= s >>> opposed to the top 100 hits sorted by field A? =A0Just pass a higher >>> value in the search(query, ... 100, ...) call. =A0It will be slower and >>> potentially use more memory but with only 10K docs you probably won't >>> notice. >>> >>> >>> -- >>> Ian. >>> >>> >>> >>> On Tue, Jun 26, 2012 at 4:05 AM, Yogesh patel >>> wrote: >>> > Hi, >>> > >>> > I have one query of lucene about sort. >>> > >>> > I have 10000 documents in my index which having fields A,B,C,D. i wan= t >>> > first 100 results in my query but they must be sort by field A. >>> > Suppose I have query "B:abc". >>> > >>> > so used below code with search : >>> > >>> > qp is object of query parser. >>> > >>> > Query query=3Dqp.parse("B:abc"); >>> > >>> > Sort sort=3D new Sort(new SortField("A",SortField.STRING_VAL,true)); >>> > >>> > hits =3D searcher.search(query, null,100,sort); >>> > >>> > but when i search above way.it gives me result in sorting but sorting >>> > applies to only matching first 100 results.It search first 100 result= s >>> and >>> > then sort. I want first 100 sorted descending of Field A with matchin= g >>> > query. >>> > >>> > Is it possible in Lucene? >>> > >>> > Thanks >>> > >>> > *Regards, >>> > >>> > Yogesh Patel* >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >>> For additional commands, e-mail: java-user-help@lucene.apache.org >>> >>> >> >> >> -- >> * >> >> Regards, >> >> Yogesh Patel* > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org