0

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?

torquestomp
  • 3,304
  • 19
  • 26

1 Answers1

1

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.

femtoRgon
  • 32,893
  • 7
  • 60
  • 87