Re: How to get field names and types from an IndexSearcher

2013-02-06 Thread Rolf Veen
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 that is used in the method StandardQueryPa

Re: How to get field names and types from an IndexSearcher

2013-02-01 Thread Rolf Veen
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 numerical

Re: How to get field names and types from an IndexSearcher

2013-02-01 Thread Michael McCandless
On Fri, Feb 1, 2013 at 3:17 AM, Rolf Veen wrote: > On Thu, Jan 31, 2013 at 9:55 PM, Michael McCandless > wrote: > >> But are you wanting to, eg, make a NumericRangeQuery if you detect the >> field was indexed numerically, and otherwise a TermRangeQuery, or >> something...? (Not easy) > > This is

Re: How to get field names and types from an IndexSearcher

2013-02-01 Thread Rolf Veen
On Thu, Jan 31, 2013 at 9:55 PM, Michael McCandless wrote: > But are you wanting to, eg, make a NumericRangeQuery if you detect the > field was indexed numerically, and otherwise a TermRangeQuery, or > something...? (Not easy) This is what I want, yes. But I begin to understand that this is not

Re: How to get field names and types from an IndexSearcher

2013-01-31 Thread Michael McCandless
On Thu, Jan 31, 2013 at 7:31 AM, Rolf Veen wrote: > Thank you, Mike. > > I didn't state why I need this. I want to be able to send > a query to some QueryParser that understands "field:1" > regardless if 'field' was added as StringField or LongField, > for example. I do not want to rely on schema

Re: How to get field names and types from an IndexSearcher

2013-01-31 Thread Rolf Veen
Thank you, Mike. I didn't state why I need this. I want to be able to send a query to some QueryParser that understands "field:1" regardless if 'field' was added as StringField or LongField, for example. I do not want to rely on schema information if I can avoid it, and rather use a smart QueryPar

Re: How to get field names and types from an IndexSearcher

2013-01-31 Thread Michael McCandless
Getting the FieldInfos from each AtomicReader is the right approach! But, FieldInfos won't tell you which XXXField class was used for the indexing: that information is not fully preserved ... Mike McCandless http://blog.mikemccandless.com On Thu, Jan 31, 2013 at 6:33 AM, Rolf Veen wrote: > Hel