lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yonik Seeley <yo...@lucidimagination.com>
Subject Re: Equality Numeric Query
Date Wed, 11 Nov 2009 14:06:14 GMT
On Wed, Nov 11, 2009 at 8:54 AM, Shai Erera <serera@gmail.com> wrote:
> I index documents with numeric fields using the new Numeric package. I
> execute two types of queries: range queries (for example, [1 TO 20}) and
> equality queries (for example 24.75). Don't mind the syntax.
>
> Currently, to execute the equality query, I create a NumericRangeQuery with
> the lower/upper value being 24.75 and both limits are set to inclusive. Two
> questions:
> 1) Is there a better approach? For example, if I had indexed the values as
> separate terms, I could create a TermQuery.

Create a term query on NumericUtils.floatToPrefixCoded(24.75f)

> 2) Can I run into precision issues such that 24.751 will be matched as well?

Nope... every numeric indexed value has it's precision indexed along
with it as a prefix, so there will be no false matches.

-Yonik
http://www.lucidimagination.com

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


Mime
View raw message