Class LegacyNumericUtils

  • Deprecated. 
    Please use PointValues instead.

    public final class LegacyNumericUtils
    extends Object
    This is a helper class to generate prefix-encoded representations for numerical values and supplies converters to represent float/double values as sortable integers/longs.

    To quickly execute range queries in Apache Lucene, a range is divided recursively into multiple intervals for searching: The center of the range is searched only with the lowest possible precision in the trie, while the boundaries are matched more exactly. This reduces the number of terms dramatically.

    This class generates terms to achieve this: First the numerical integer values need to be converted to bytes. For that integer values (32 bit or 64 bit) are made unsigned and the bits are converted to ASCII chars with each 7 bit. The resulting byte[] is sortable like the original integer value (even using UTF-8 sort order). Each value is also prefixed (in the first char) by the shift value (number of bits removed) used during encoding.

    For easy usage, the trie algorithm is implemented for indexing inside LegacyNumericTokenStream that can index int, long, float, and double. For querying, LegacyNumericRangeQuery implements the query part for the same data types.

    2.9, API changed non backwards-compliant in 4.0