java既然Lucene 4.1中不存在TermEnum,如何从IndexReader中获取字段?
Lucene 4.1中的3.6代码的等价物是什么:
IndexReader ir = IndexReader.open(dir);
TermEnum termEnum = ir.terms(t);
这在我的许多测试用例中都有使用
我查过移民指南,上面写着
TermEnum termsEnum = ...;
while(termsEnum.next()) {
Term t = termsEnum.term();
System.out.println("field=" + t.field() + "; text=" + t.text());
}
Do this:
for(String field : fields) {
Terms terms = fields.terms(field);
TermsEnum termsEnum = terms.iterator(null);
BytesRef text;
while((text = termsEnum.next()) != null) {
System.out.println("field=" + field + "; text=" + text.utf8ToString());
}
}
但字段从哪里来,如何从IndexReader中获取字段
共 (0) 个答案