tags:

views:

85

answers:

2
+1  Q: 

lucene larger than

Hi, Does anybody of you guys know how to search all the numbers larget than a specified one?

for example: all the document number > 65

i tried like: documentNumber: [65 TO *] but i receive exception, as lucene expected to parse a number there not a *.

Thanks in advance!

A: 

I know nothing about Lucene really, but just as a random thought, have you tried just using a very big number instead of *?

[65 TO 99999999]

Pick the largest number the datatype can handle (assuming there is such a thing) or at least a larger number than would possibly be used.

Jon Skeet
+1  A: 

Jon is almost right, but you also need to pad your numbers, as numerical fields are ordered lexicographically. Thus, 1243 is considered smaller than 65. Suppose you have 20000 documents. You have to pad document numbers below 10000 with leading zeros, such as 00065, 01243, etc. The exact syntax for your query will be

documentnumber:{00065 TO 20000]

, as you do not want 65 in the range. Please see this question for details, and the official syntax.

Yuval F