是否可以遍历存储在 Lucene Index 中的文档? [英] Is it possible to iterate through documents stored in Lucene Index?

查看:20
本文介绍了是否可以遍历存储在 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 中的文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆