lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sergiu gordea <gser...@ifit.uni-klu.ac.at>
Subject Re: Finding minimum and maximum value of a field?
Date Tue, 07 Jun 2005 07:10:19 GMT
I think that the solution is to sort the results and to get the first 
result.

See:

*org.apache.lucene.search.Sort

*

Best,

 Sergiu




 Kevin Burton wrote:

> Andrew Boyd wrote:
>
>> How about using range query?
>>
>> private Term begin, end;
>>
>> begin = new Term("dateField",  
>> DateTools.dateToString(Date.valueOf(<"backInTimeStringDate">)));
>> end = new Term("dateField",  
>> DateTools.dateToString(Date.valueOf(<"farFutureStringDate">)));
>>
>> RangeQuery query = new RangeQuery(begin, end, true);
>>
>> IndexSearcher searcher = new IndexSearcher(directory);
>>
>> Hits hits = searcher.search(query);
>>
>> Document minDoc = hits.doc(0);
>> Document maxDoc = hits.doc(hits.length()-1);
>>
>> String minDateString = minDoc.get("dateField");
>> String maxDateString = maxDoc.get("dateField");
>>
>>  
>>
> This certainly is an interesting solution.  How would lucene score 
> this result set?  The first and last will depend on the score...
>
> I  guess I can build up a quick test........
>
> Kevin
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message