Hi AlexElba,

The problem is that Lucene only knows how to handle character strings, not 
numbers.  Lexicographically, "3" > "10", so you get the expected results 
(nothing).

The standard thing to do is transform your numbers into strings that sort as 
you want them to.  E.g., you can left-pad the "rank" field values with zeroes: 
"03", "04", ..., "10", and then create a RangeFilter over "03" .. "10".  You 
will of course need to left-zero-pad to at least the maximum character length 
of the largest rank.

Facilities to handle this problem are available in NumberTools:

<http://lucene.apache.org/java/2_4_0/api/org/apache/lucene/document/NumberTools.html>

(Note that NumberTools converts longs to base-36 fixed-length padded strings.)

More info here:

   <http://wiki.apache.org/lucene-java/SearchNumericalFields>

Steve

On 01/13/2010 at 12:51 PM, AlexElba wrote:
> 
> Hello,
> 
> I am currently using lucene 2.4 and have document with 3 fields
> 
> id
> name
> rank
> 
> and have query and filter when I am trying to use rang filter on rank I
> am not getting any result back
> 
> RangeFilter rangeFilter = new RangeFilter("rank", "3", "10", true, true);
> 
> I have documents which are in this interval
> 
> 
> Any suggestion what am I doing wrong?
> 
> Regards

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to