lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Vasilev <>
Subject Range search in numeric fields
Date Tue, 03 Apr 2007 17:44:17 GMT
Hi All,
I have the following problem:
I have to implement range search for fields that contain numbers. For 
example the field size that contains file size. The problem is that the 
numbers are not kept in strings with strikt length. There are field 
values like this: "32", "421", "1201". So when makeing search like this: 
+size:[10 TO 50], as the order for string is lexicorafical the result 
contains the documents with size 32 and 1201. I can see the following 
possible aproaches:
1. Changing indexing process so that all data entered in those fields is 
with fixed length. Example 0000032, 0000421, 0001201.
Disadvantages here are:
    - Have to be reindexed all existng indexes;
    - The index will grow a bit.

2. Generating query without ranges but including all numbers between the 
bounds - +size=10 +size=11 +size=12........ +size=49 + size=50. For 
narrow ranges it makes sense but for large ones... :)

3. Generating query with intervals (inclusive and exclusive) but the 
number of this intervals will be the same (or one more) than the 
conditions in point 2. +size:[10 TO 50] -size:[10 TO 11999999999] - 
size:[11 TO 129999999999] ... etc.

So if someone can help with some new oportunity please mail.

Thanks in advance.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message