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 QueryParser.
What would be the best approach to implement this ?

Kind regards,
Rolf.


On Thu, Jan 31, 2013 at 1:07 PM, Michael McCandless
<luc...@mikemccandless.com> wrote:
> 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 <rolf.v...@gmail.com> wrote:
>> Hello, all.
>>
>> I want to get a list of field names and types out of an IndexSearcher
>> or IndexReader (not necesarily Atomic). By type I mean if it was
>> stored as StringField, LongField, etc. Is this possible ?
>>
>> I could get the field names this way, probably not the simplest one
>> to get a unified field list:
>>
>> IndexReader reader = searcher.getIndexReader();
>>
>> for (AtomicReaderContext rc : reader.leaves()) {
>>     AtomicReader ar = rc.reader();
>>     FieldInfos fis = ar.getFieldInfos();
>>     for (FieldInfo fi : fis)
>>       System.out.println(fi.name);
>> }
>>
>>
>> Kind regards,
>> Rolf.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
>> For additional commands, e-mail: java-user-h...@lucene.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>

---------------------------------------------------------------------
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