You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Kevin Burton <bu...@rojo.com> on 2005/05/31 09:06:50 UTC

Finding minimum and maximum value of a field?

I have an index with a date field.  I want to quickly find the minimum 
and maximum values in the index.

Is there a quick way to do this?  I looked at using TermInfos and 
finding the first one but how to I find the last?

I also tried the new sort API and the performance was horrible :-/

Any ideas?

Kevin

-- 


Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com. 
See irc.freenode.net #rojo if you want to chat.

Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

   Kevin A. Burton, Location - San Francisco, CA
      AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412 


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


Re: Finding minimum and maximum value of a field?

Posted by John Wang <jo...@gmail.com>.
You can try to load the fieldcache:

if you get the StringIndex from the fieldcache, the last element in
the lookup array is the largest value (lexically) in the field.

-John


On 6/7/05, sergiu gordea <gs...@ifit.uni-klu.ac.at> wrote:
> 
> 
> Kevin Burton wrote:
> 
> > I have an index with a date field.  I want to quickly find the minimum
> > and maximum values in the index.
> >
> > Is there a quick way to do this?  I looked at using TermInfos and
> > finding the first one but how to I find the last?
> >
> > I also tried the new sort API and the performance was horrible :-/
> >
> > Any ideas?
> 
> You may keep a history of the MIN and MAX values in an external file.
> Let's say, you can write in a text file the MIN_DATE and MAX_DATE,
> and keep them up to date when indexing, deleting documents.
> 
> Best,
> 
>  Sergiu
> 
> >
> > Kevin
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
>

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


Re: Finding minimum and maximum value of a field?

Posted by sergiu gordea <gs...@ifit.uni-klu.ac.at>.

Kevin Burton wrote:

> I have an index with a date field.  I want to quickly find the minimum 
> and maximum values in the index.
>
> Is there a quick way to do this?  I looked at using TermInfos and 
> finding the first one but how to I find the last?
>
> I also tried the new sort API and the performance was horrible :-/
>
> Any ideas?

You may keep a history of the MIN and MAX values in an external file.
Let's say, you can write in a text file the MIN_DATE and MAX_DATE,
and keep them up to date when indexing, deleting documents.

Best,

 Sergiu

>
> Kevin
>


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


Re: Finding minimum and maximum value of a field?

Posted by Tony Schwartz <to...@simpleobjects.com>.
Only way I see to do this is to get a TermEnum for that field, and grab the first.  Then
iterate until you find the last one.  This is similar behavior to the TermEnum.skipTo
method.  A better solution would be to record the minimum and maximum dates in the index
as you index them.  Each time you insert a new date, update the min/max if needed.  This
data would reside outside the index of course.


Tony Schwartz
tony@simpleobjects.com
"What we need is more cowbell."

> I have an index with a date field.  I want to quickly find the minimum
> and maximum values in the index.
>
> Is there a quick way to do this?  I looked at using TermInfos and
> finding the first one but how to I find the last?
>
> I also tried the new sort API and the performance was horrible :-/
>
> Any ideas?
>
> Kevin
>
> --
>
>
> Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com.
> See irc.freenode.net #rojo if you want to chat.
>
> Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html
>
>    Kevin A. Burton, Location - San Francisco, CA
>       AIM/YIM - sfburtonator,  Web - http://peerfear.org/
> GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


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