问题描述
我们正在从这里升级Lucene 3.3.0到Lucene 4.2.1,我似乎无法找到旧的IndexReader.getFieldNames方法的替代品。谷歌搜索提出,其中提到了一个新的IndexReader.getFieldInfos方法,但是是实验性的,似乎不再是 - 这条路很冷。
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.
如何在Lucene 4中复制IndexReader.getFieldNames的行为?
How can I replicate the behavior of IndexReader.getFieldNames in Lucene 4?
推荐答案
你可以得到,。
类似于:
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.
}
看一下了解更多信息,有关于IndexReader - > AtomicReader的部分。如果您还不熟悉这一变化,您可能会发现它有用的信息。
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.
这篇关于IndexReader.getFieldNames Lucene 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!