lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shai Erera <ser...@gmail.com>
Subject Re: Paging in a Lucene search
Date Thu, 06 Aug 2009 10:02:40 GMT
If you pass reader.maxDoc(), it will create a heap (array) of size
reader.maxDoc() and is not recommended.
Instead, if you display the first page of results, you should pass 10
(assuming you display 10 results).
You can call TopFieldDocs.totalHits to get the total number of matching
results.

Then if you want to display the second page of results, pass 20, and take
results 11-20 and so on.

Does that help?

Shai

On Thu, Aug 6, 2009 at 12:59 PM, Savvas-Andreas Moysidis <
savvas.andreas.moysidis@googlemail.com> wrote:

> Hello,
>
> I'd like to ask if anybody has any thoughts on the best strategy to use
> when
> implementing a paging scenario in a Lucene search.
>
> In order to implement my paging list before the view is rendered I need to
> know the total number of documents this particular search would return but
> I
> still need to only load the documents of the specific page that has been
> requested.
>
> I'm thinking of using the search variant of :
>
> *TopFieldDocs search(Query query, Filter filter, int n,Sort sort);*
>
> since I need sorting and filtering and passing indeaxReader.maxDoc() for n.
> Will that create an array of size indeaxReader.maxDoc() ?
>
> After the search is finished I can retrieve only the documents I'm
> interested by using the sub-list of TopFieldDocs I've worked out.
>
> In the HitCollector docs :
>
>
> http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/search/HitCollector.html
> I can see a way to use a BitSet but I'm not quite sure how this can be used
> to retrieve documents.
>
> Any alternatives/better ideas?
>
>
> thanks,
> Savvas
>

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