Mailing List Archive

searching between two fields
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
Re: searching between two fields [ In reply to ]
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.
Re: searching between two fields [ In reply to ]
On Apr 26, 2005, at 2:18 PM, 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?

Yes.

I do this with my work with years. The data I index has year strings
like this: "1837-65" but a search for year:1856 will find this
document. I do this by expanding the terms indexed so that the year
field has a term for each year in the range. In your case, you could
index a "temp" field with every unit value between 100 and 200
inclusively.

I recommend you post to java-user@lucene rather than general@lucene.

Erik
RE: searching between two fields [ In reply to ]
Is it possible to view the archives of java-user@lucene on the web? It
looked like it was no longer on the lucene web site, that's why I was
using general@lucene. Before when a link to the java-user list was
still there, I kept getting an error trying to view it.

Thanks,
Peter

-----Original Message-----
From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
Sent: Tuesday, April 26, 2005 2:07 PM
To: general@lucene.apache.org
Subject: Re: searching between two fields


On Apr 26, 2005, at 2:18 PM, 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?

Yes.

I do this with my work with years. The data I index has year strings
like this: "1837-65" but a search for year:1856 will find this
document. I do this by expanding the terms indexed so that the year
field has a term for each year in the range. In your case, you could
index a "temp" field with every unit value between 100 and 200
inclusively.

I recommend you post to java-user@lucene rather than general@lucene.

Erik
Re: searching between two fields [ In reply to ]
Kipping, Peter wrote:
> Is it possible to view the archives of java-user@lucene on the web? It
> looked like it was no longer on the lucene web site, that's why I was
> using general@lucene. Before when a link to the java-user list was
> still there, I kept getting an error trying to view it.

Archives are available at:

http://www.mail-archive.com/index.php?hunt=lucene

We should get the other lucene mailing lists archived there, like
general, and java-commits.

Doug