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?

4

1 回答 1

1

您可以使用AtomicReader.getFieldInfos()获取FieldInfos。 类似于以下内容:

for (FieldInfo info : atomicReader.getFieldInfos().iterator()) {
    String name = info.name;
    //Whatever you need to do with the name.
}

查看迁移指南了解更多信息,其中有一个关于 IndexReader -> AtomicReader 的部分。如果您还不熟悉该更改,您可能会发现它有用的信息。

于 2013-04-30T17:58:51.647 回答