lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject what's the best practice for getting "next page" of hits?
Date Thu, 19 Feb 2009 03:29:56 GMT

So, I may well be missing something here, but: I use 

<pseudoCode>, null, count, new Sort());</pseudoCode>

to get an instance of TopFieldDocs (the "Hits" is deprecated). So far, all fine; I get a bunch
of documents. Now, what is the Lucene-best-practice for getting the *next* batch of size "count"?
(Didn't see this discussed anywhere, but maybe I missed it.) 

a) I could guess that my users will never want more than "N*count", for some value of N, request
that right up front, and do all my own "paging" using the one TopFieldDocs instance; 

b) I could assume that (a) will be an inefficient memory and time hog, and when the user clicks
"Next" (or whatever), then ... (with i starting at "1") get a new TopFieldDocs with "(++i)*count",
and out of that discard the first "i*count" items? In the limit (as i => N) that uses up
just as much space and memory, but does so lazily (better); 

c) some compromise of (a) and (b), where I get M*count, do my own paging, and when the user
asks for the (i+1)==(M+1)-th batch, then get another M*count (maybe faster, but also maybe
bigger amortized memory footprint); 

d) something else? (I'd hope for something like a search() method with some parameter saying,
in effect, "such and such a range of hits" ...) 


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message