Tobias
Tobias

Reputation: 53

How to query for int and float elements in lucene

I'm using Lucene 5.3.1 to build up an index each time my eclipse application loads a project. My index stores numerical information of the type Long and Double. For indexing I use the fields

org.apache.lucene.document.LongField 

and

org.apache.lucene.document.DoubleField

Simplified example:

final long valueL =...;

final double valueD =...;

new LongField(VALUE, valueL, Field.Store.YES) 

new LongField(VALUE, valueD, Field.Store.YES)

If I want to search(NumericRangeQuery) for numeric values bigger than n, the result only takes elements of the index into account which are from the same type as n. E.g. If n is Double I only receive Double elements from the index and all Long elements are ignored.

"n > 2.1"   -->   (+VALUE:{2.1 TO *})

Returns:

3.4

2.1

But not

5

And so on.

Is there a way to get Long and Double results in one query?

Upvotes: 2

Views: 985

Answers (1)

Amey Jadiye
Amey Jadiye

Reputation: 3154

This should work :

(+VALUE:{2.1 TO *} +VALUE:{2 TO *})

Upvotes: 1

Related Questions