lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tomer Gabel <>
Subject Re: Order the index by timestamp field and Get n documents
Date Sun, 16 Nov 2008 10:28:15 GMT

Possibly the fastest way to do this is to use a sortable timestamp field
(e.g. padded long) and use a TermEnumerator, which always gives a
lexicographically-sorted enumeration. Since you'd probably prefer a "most
recent" policy you may need to come up with a reverse-timestamp scheme (e.g.
instead of zero-padded "milliseconds since epoch" you may prefer zero-padded
"milliseconds 'till year 3000" values).

Lucene doesn't handle this type of queries very efficiently, however, so you
may prefer an SQL database instead (or in addition).


Cool The Breezer wrote:
> Hi,
>    In my index, there is a field called timestamp which is long value of
> date. I am  trying to get sort all documents by timestamp and get N
> documents. 
> I am trying to find a way to create a query like "timestamp > 0" and then
> order the result by timestamp and get N fields. However I am not able to
> do that. Suggest me the best way. Or there are any lowlevel method
> available for the same.
> I am using Lucene 2.3.1 and looking into method search(Weight weight,
> Filter filter, int nDocs, Sort sort) in IndexSearcher. Trying to know how
> to create a Weight object.
> Anyway, I would really appreciate your suggestion....
> -RB
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

-- Tomer Gabel 

View this message in context:
Sent from the Lucene - Java Users mailing list archive at

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

View raw message