本文介绍了是否可以遍历Lucene Index中存储的文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些文档存储在带有docId字段的Lucene索引中.我想获取存储在索引中的所有docId.还有一个问题.文档数量大约为300 000,所以我希望以大小为500的块形式获取此docId.是否可以这样做?
I have some documents stored in a Lucene index with a docId field.I want to get all docIds stored in the index. There is also a problem. Number of documents is about 300 000 so I would prefer to get this docIds in chunks of size 500. Is it possible to do so?
推荐答案
IndexReader reader = // create IndexReader
for (int i=0; i<reader.maxDoc(); i++) {
if (reader.isDeleted(i))
continue;
Document doc = reader.document(i);
String docId = doc.get("docId");
// do something with docId here...
}
这篇关于是否可以遍历Lucene Index中存储的文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!