lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Carlson <>
Subject Re: Sorting
Date Thu, 20 Jun 2002 04:48:14 GMT
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

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.


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
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message