lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yonik Seeley <yo...@lucidimagination.com>
Subject Re: Hits and TopDoc
Date Tue, 20 Oct 2009 21:22:12 GMT
On Tue, Oct 20, 2009 at 5:03 PM, Nathan Howard <natehoward1@gmail.com> wrote:
> This is sort of related to the above question, but I'm trying to update some
> (now depricated) Java/Lucene code that I've become aware of once we started
> using 2.4.1 (we were previously using 2.3.2):
>
> Hits results = MultiSearcher.search(Query));
>
> int start = currentPage * resultsPerPage;
> int stop = (currentPage + 1) * resultsPerPage();
>
> for(int x = start; (x < searchResults.length()) && (x < stop); x++)
> {
>    Document doc = searchResults.doc(x);
>    // do search post-processing with the Document
> }
>
> Results per page is normally small (10ish or so).
>
> I'm having difficulty figuring out how to get TopDocs to replicate this
> paging functionality (which the application must maintain).

You do it tthe same way basically... calculate the biggest doc you
need ("stop"-1 in your code), ask for that many TopDocs, and then
iterate over the page you want, calling
searcher.doc(topDocs.scoreDocs[x].doc)

-Yonik
http://www.lucidimagination.com

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message