lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter W." <pe...@marketingbrokers.com>
Subject Re: pagination
Date Thu, 22 Feb 2007 22:01:55 GMT
Hello,

This snippet may help to understand TopDocs:

http://mail-archives.apache.org/mod_mbox/lucene-general/200508.mbox/% 
3C430CD197.6080609@apache.org%3E

Also, paging through Lucene results is 'do-it-yourself' exercise using
hits.length() until someone contributes a good implementation.

Oversimplifying, if you want 10 hits per page:

hitsperpage equals ten;

-if hits length is less than ten, you have one page
-else if hits length/hitsperpage modulos is 0, that's your pagecount
-else hits length/hitsperpage is your pagecount, modulos is for your  
last page

You will also need a variable to keep track of which page you are on  
and a static
method which returns min/max values to be included in your iteration  
loop.

You can also see my previous attempt at solving this:

http://www.gossamer-threads.com/lists/lucene/java-user/43595

Regards,

Peter W.

On Feb 21, 2007, at 6:32 AM, Kainth, Sachin wrote:

> I might be missing something because TopDocs seems to only be about
> finding the relevancy of documents and HitCollector doesn't seem to be
> relavent either.
>
> -----Original Message-----
> From: Erick Erickson [mailto:erickerickson@gmail.com]
> Sent: 21 February 2007 13:08
> To: java-user@lucene.apache.org
> Subject: Re: pagination
>
> See TopDocs, HitCollector, etc. Don't iterate through a Hits  
> objects to
> get docs beyond, say, 100 since it's designed to efficiently return  
> the
> first 100 documents but re-executes the queries each 100 or so  
> times you
> advance to the next document.
>
> Erick
>
> On 2/21/07, Kainth, Sachin <Sachin.Kainth@atkinsglobal.com> wrote:
>>
>> Hello,
>>
>> I was wondering if Lucene provides any mechanism which helps in
>> pagination.  In other words is there a way to return the first 10 of
>> 500 results and then the  next 10 and so on.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message