lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rolf Veen <>
Subject Re: How to get field names and types from an IndexSearcher
Date Wed, 06 Feb 2013 10:30:00 GMT
Just for the record, the solution that I adopted is as follows:

- Create a setType(String field, String type) and call it for any known
  numeric fields, before adding any document. This method saves
  the type definition in a file and also sets the Map<String,NumericConfig>
  that is used in the method StandardQueryParser.setNumericConfigMap().

This method has the drawback that the types must be known in advance
(that is, it is a schema), but it's more robust the guessing the types from
the documents itself (as my initial request implied).

Kind regards,

On Fri, Feb 1, 2013 at 3:22 PM, Rolf Veen <> wrote:
> On Fri, Feb 1, 2013 at 12:43 PM, Michael McCandless
> <> wrote:
>> There is actually one way to check if a field was indexed numerically:
>> you can seek to the first term in the field, and attempt to parse it
>> as a long/float/etc., and if that throws a NumberFormatException, it
>> was indexed numerically.
>> Ie, numeric fields are indexed using the formats from
>> oal.util.NumericUtils, which will not parse as "normal" numbers.
>> This is what Lucene's FieldCache does to check how to decode numeric
>> values when uninverting ...
> Very good info.
> Thank you, Mike.

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

View raw message