Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@apache.org Received: (qmail 54716 invoked from network); 20 Jun 2002 04:48:16 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 20 Jun 2002 04:48:16 -0000 Received: (qmail 21931 invoked by uid 97); 20 Jun 2002 04:48:29 -0000 Delivered-To: qmlist-jakarta-archive-lucene-user@jakarta.apache.org Received: (qmail 21882 invoked by uid 97); 20 Jun 2002 04:48:28 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 21870 invoked by uid 98); 20 Jun 2002 04:48:27 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Errors-To: User-Agent: Microsoft-Entourage/10.1.0.2006 Date: Wed, 19 Jun 2002 21:48:14 -0700 Subject: Re: Sorting From: Peter Carlson To: Lucene Users List Message-ID: In-Reply-To: Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi Fanny, This is a bit tricky because Lucene is optimized to not get the contents of a given Document until asked. This is a somewhat expensive operation and if sorting by getting the contents of the field will potentially slow down the search results dramatically. There has been some discussion on this and the current idea is to create a separate array which contains the field contents for every record with an index of the global documentID. Then when you get the results back, you sort the results by getting the data from the array (which is already in memory) instead of from the index. I have done this already and have moved by contribution to the Lucene-Sandbox. It is encapsulated into the SearchBean directory http://cvs.apache.org/viewcvs/jakarta-lucene-sandbox/contributions/searchbea n/ I have not completely moved it over, but this should give you a good start. The real place to look is in the HitsIterator. I hope this helps. --Peter On 6/19/02 10:50 AM, "Fanny Yeung" wrote: > Hi, > > Thanks the reply from Ype. Sorry, I am a newbie of lucene, would Ype give me > more details on how to implement it? Would the sorting affect the > performance a lot? > > Many Thanks, > > Fanny > >> From: Ype Kingma >> Reply-To: "Lucene Users List" >> To: "Lucene Users List" >> Subject: Re: Sorting >> Date: Wed, 19 Jun 2002 19:40:59 +0100 >> >> Fanny, >>> >>> I want to implement search function using Lucene. As I need to sort the >> result by number of indexed fields. (say 3 indexed fields). I am wondering >> how can I implement that. Can anyone give me some hints? >> >> The easiest way is to create an extra stored field with the number of >> remaining >> fields. >> You could also store the names of the remaining fields and count these >> before sorting. This gives you the bonus of allowing to search for the >> presence of a field. >> >> Regards, >> Ype >> >> -- >> >> -- >> To unsubscribe, e-mail: >> >> For additional commands, e-mail: >> > > > _________________________________________________________________ > Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. > > > -- > To unsubscribe, e-mail: > For additional commands, e-mail: > > -- To unsubscribe, e-mail: For additional commands, e-mail: