lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: Best way for paging with TopDocs class?
Date Thu, 16 Apr 2009 15:31:50 GMT
Well, under the covers, the old Hits object *was* reloading the first N
pages to
get page N + 1, you just didn't see it. Hits also had other, undesirable
behaviors.

But "loading docs N-1 times" it's not as expensive as you perhaps fear.
To get a sorted list, you must sort the entire set of documents. Which
means to get, say, page 3 in some sort order, somewhere, sometime
you must keep track of the scores for documents 1-200 in order to
insure that docs 201-300 are really in the proper place. Since a
TopDocs is just an int/float pair we're not talking about much memory.

So I'd advise just going about it as you outlined. The *real* savings would
be in not re-executing the search every page, but I wouldn't think about
a caching scheme unless you demonstrate a problem. And if you were
making due with Hits before, I suspect this isn't really a problem....

Best
Erick


On Thu, Apr 16, 2009 at 10:58 AM, Ivan Vasilev <ivasilev@sirma.bg> wrote:

> Hi All,
>
> As Hits class was deprecated in current Lucene and is expected to be
> excluded from Lucene 3.0 we decided to change our code so that to use
> TopDocs class.
> Our app provides paging and now we are uondering what is the bset way to do
> it with th TopDocs. I can see only this possibility:
> 1. User opens page 1 - we load by searcher.search(..., docNum, ... ) method
> as many docs as for page 1;
> 2. User opens page 2 - we load as many results as the amount for page 1 and
> page 2 (note that docs for page 1 are loaded again);
> ...
> N. User opens page n - we load as many docs as the amount of all pages from
> #1 to #N (note that page 1 docs were loaded N-1 times, page 2 docs N-2 times
> etc).
>
> With Hits class this loading of documents of previous pages was avoided -
> they were loaded once and when needed docs for the next page Hits just
> loaded the next portion of docs without reloading the previous pages.
>
> So my question is:
> Is there better way for paging with the class TopDocs than the one that I
> describe here?
>
> Thanks in Advance,
> Ivan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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