lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: Numbertools and efficient sorting
Date Fri, 09 Jun 2006 22:21:30 GMT

: I have an integer field that I've indexed after converting to a string
: using NumberTools.longToString().
: Now I want to sort my results using this field.  Everything works when
: treating the field as a string, but is very slow and memory intensive.
: I want to use INT sorting instead, but these strings can not be parsed
: back into integers by Java's built in parsing functions, which is

1) Take a look at FieldCache.IntParser and
FieldCache.getInts(IndexReader,String,IntParser) .. you can use it in your
own custom SortComparatorSource and use it when building your Sort Field.

2) unless you are using a MultiSearcher, sorting by a string shouldn't
take any more tiem then sorting on an int -- String sorting only looks at
the ordinal value of the string for each doc (which is an int) ... it will
certainly take more memory however, and the Strings themselves are kept in
a big array.  if you really are seeing an obvious difference in the time
it takes to sort on strings versus ints, then i'm guessing that either you
aren't looking at a significant number of queries, or you aren't reusing
the same IndexSearcher/IndexReader or multiple searchers, so you're paying
the hit of building hte FieldCache everytime.


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

View raw message