lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Carlson <>
Subject Re: 2 Questions
Date Tue, 30 Apr 2002 20:20:09 GMT
Lucene does not currently support sorting by fields (such as a date field).

This is one of the to do items.  I have implemented a sort by date on top of
Lucene (not built into Lucene's core), and plan to add it to the
contributions section once I get it a little more documented.

The method I used was suggested by Doug and is to create an array at startup
with contents of the field you want to sort by (in my case a date field).
For my list of 100,000 docs, this takes about 3 seconds. Then after you get
back the results from the search, look up the Lucene unique doc Ids (you'll
have to change the Hits interface to make this ID accessible) in the array,
get the field value and sort it. For my search results of about 15000, it
adds about .04 seconds to the search. It does get slower with more results.
Note that this is could be optimized with a TopDocs like implementation to
only sort the items that are near the top.


On 4/30/02 11:38 AM, "Joel Bernstein" <> wrote:

> The DateFilter interface seems only to filter (include/exlcude) the results
> by date.
> Does it also sort the results by date?
> Thanks

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

View raw message