Reputation: 3344
We're upgrading from Lucene 3.3.0 to Lucene 4.2.1 over here, and I can't seem to find the replacement for the old IndexReader.getFieldNames method. Googling brings up this ticket which speaks of a new IndexReader.getFieldInfos method, but that was experimental and seems to be around no longer - the trail is cold.
How can I replicate the behavior of IndexReader.getFieldNames in Lucene 4?
Upvotes: 0
Views: 754
Reputation: 33351
You can get the FieldInfos with AtomicReader.getFieldInfos().
Something along the lines of:
for (FieldInfo info : atomicReader.getFieldInfos().iterator()) {
String name = info.name;
//Whatever you need to do with the name.
}
Take a look at the Migration Guide for more info, there's a section about IndexReader -> AtomicReader. If you aren't acquainted with that change yet, you'll likely find it useful information.
Upvotes: 1