11

Lucene の Java バージョンを使用して、インデックス内のドキュメントの数をどのように確認しますか?

4

5 に答える 5

17

IndexReader には、必要なメソッド、特に numDocs が含まれています

http://lucene.apache.org/core/3_6_0/api/all/org/apache/lucene/index/IndexReader.html#numDocs()

于 2009-01-14T11:05:18.353 に答える
4

Javaを使用すると、次のようなドキュメントの数を見つけることができます:

IndexReader reader = IndexReader.open(FSDirectory.open(indexDirectory));
System.out.println(reader.maxDoc()); //this will give ya what you need.
于 2012-12-25T09:54:25.333 に答える
3

公式ドキュメント: http://lucene.apache.org/java/2_4_0/api/org/apache/lucene/index/IndexReader.html#numDocs()

于 2009-01-14T11:31:35.603 に答える
0

IndexReaderを使用する最近の Lucene バージョンでは、次の Kotlin スニペットがその役割を果たします。

DirectoryReader.open(directory).use { reader ->
    println(reader.numDocs())
}

ここで、インデックスを含むDirectorydirectoryのインスタンスです。

于 2021-11-21T12:48:41.057 に答える