lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Spencer <dave-lucene-u...@tropo.com>
Subject Re: Iterating TermEnum backwards
Date Thu, 26 Feb 2004 16:45:01 GMT
Matt Quail wrote:

> Hi all,
>
> Is there any way to iterate through a TermEnum backwards? Okay, I know
> that there isn't a way to do this via the TermEnum class, but is it
> "implementable" on top of the underlying Lucene datastore?
>
> My particular problem is this:
>
> I have an index of documents, each document has a "date" field (I'm
> using DateField). Most documents have a different date, so the number of
> unique dates is close to the number of documents.
>
> I want to find the top N most recent dates, but I don't want to have to
> iterate through ALL of them first. NB: With DateField, the earlier dates
> are lexocographically smaller. (I also want to find the most recent N
> less than some date D).
>
> I know I could "invert" my dates (something like MAX_LONG - date) to get
> the REVERSE order, but I want to be able to do "least recent" and "most
> recent".

Maybe add another field, a "backwards" date, such that existing api will 
return more recent ones first?!

>
> Is iterating over a TermEnum "impossible", or should I dig further, and
> possibly submit a patch?
>
>
> =Matt
>
> PS: my current solution is to do a binary search between MIN and MAX,
> halving my search space until I find close to N matching documents.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message