0

I'm applying the following Lucene query predicate in order to get all inclusive numbers in 2 to 6 range:

value:[2 TO 6]

and receive the documents with the following values:

567986400000
567986400000
567986400000
536450400000
536450400000
599608800000
536450400000
567986400000

I'm interested in the numeric range query and obviously, for example, the Long value 567986400000 is not in the range of [2 TO 6]. Looks like the range searches are strings and I don't know how to workaround it in mine application for the different numeric values.

How to properly use numeric range queries in Lucene?

dom
  • 732
  • 7
  • 19
alexanoid
  • 24,051
  • 54
  • 210
  • 410
  • how do you index your document and especially what kind of Field is your field which you use the range query? – dom May 28 '18 at 13:07
  • honestly, I do not control this process because I use range queries over the manual index which is built over Lucene in Neo4j database. I have these indexes out of the box and I can only provide the predicate to search in the index. – alexanoid May 28 '18 at 13:37
  • well it's pretty important because you need to use specific fields for range queries. will add an answer – dom May 28 '18 at 13:39

1 Answers1

1

To achieve a proper range query you need to use specific defined fields from lucene. See Field javadoc

  • IntPoint: int indexed for exact/range queries.
  • LongPoint: long indexed for exact/range queries.
  • FloatPoint: float indexed for exact/range queries.
  • DoublePoint: double indexed for exact/range queries.

So you need to be sure that your field you add this query is one of this types. As you said you use a Neo4j generated lucene index. There has to be an option to create this kind of fields otherwise you're not able to execute proper range queries.

dom
  • 732
  • 7
  • 19