lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Elschot <paul.elsc...@xs4all.nl>
Subject Re: searching between two fields
Date Tue, 26 Apr 2005 19:02:00 GMT
On Tuesday 26 April 2005 20:18, Kipping, Peter wrote:
> Suppose I have a document with two fields, min_temp = 100 and max_temp =
> 200.  If a user inputs a search value of 150 the document should be
> returned.  Is it possible to make this happen with lucene?
> 
> Thanks,
> Peter

Yes, but it would require some extra investments.

The query would be a BooleanQuery of two required RangeQuery's,
with the numbers indexed as strings with zero prefixes to make
the numerical comparison identical to the string comparison used
in by the index.

In case there are a lot of different temperature values to be indexed,
it would probably be good to also index prefixes of some well chosen lengths
of the indexed minimum and maximum temperatures and adapt the  term
enumeration in the RangeQuery to use the prefixes whenever possible.

Regards,
Paul Elschot.


Mime
View raw message