开发者

Lucene.net search range by order - paging

I got a lucene.net index with bunch of documents. I pull these with MVC request and return to client as JSON. I want to return only top N documents starting from index I want. I need that to minimize data flow between server and client. What I need is something like:

1) First query- Get top 20 docs

2) Second query - Get top 20 docs beginning from 20 - would be 21 - 41

3) .... and so on

Lucene allows me to set top ite开发者_如何学Goms. But it only count those from the beginning from the index. Is there a build-in possibility to set start index for that ? Probably some advanced Indexer I am missing in lucene.net or something..

Thanks!


Take a look at this blog that explains pagination in lucene.

The crux of it is this:

int start = 20; int pageSize = 20;
Query query = qp.parse(searchTerm);  
TopDocs hits = searcher.search(query, maxNumberOfResults);  
for (int i = start; i < start + pageSize && i < hits.Length(); i++) {  
    int docId = hits.scoreDocs[i].doc;  
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜