lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Bowesman <...@teamware.com>
Subject Re: Range search in numeric fields
Date Wed, 04 Apr 2007 00:16:56 GMT
Ivan Vasilev wrote:
> 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.

Look at Sols NumberUtils.int2sortableStr().  It will mean reindexing, but the 
number size has fixed storage size - 6 bytes for ints.  It converts numbers to a 
3 char Unicode representation which is sortable and therefore range searchable.

Antony



---------------------------------------------------------------------
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