Lucene .NET结果子集

Mat*_*att 2 lucene lucene.net

我正在使用Lucene .NET让我说我只想从结果100开始返回50个结果,我该怎么办呢?我搜索了文档,但没有找到任何东西.有什么我想念的吗?

its*_*dok 5

您的代码应如下所示:

TopDocs topDocs = indexSearcher.Search(query, null, 150);
for(int i=100, i<min(topDocs.totalHits,150); i++) {
    Document doc = indexSearcher.doc(topDocs.scoreDocs[i]);

    // Do something with the doc
}
Run Code Online (Sandbox Code Playgroud)

不要使用该Hits课程.它效率低下并且已被弃用.