lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From João Silva <galaio.si...@gmail.com>
Subject Re: Collector Pagination
Date Fri, 19 Jun 2009 13:21:59 GMT
Nice Uwe,
i'll try this.

Thanks,
Galaio

On Fri, Jun 19, 2009 at 1:33 PM, Uwe Schindler <uwe@thetaphi.de> wrote:

> To get the second page,
> Take:
> int hitsPerPage = 10;
> int pageOffset = 10;
> TopDocCollector collector = new TopDocCollector(hitsPerPage + pageOffset);
>
> For page third page take int pageOffset = 20; and so on
>
> After that your results are in hits[], for the first page in [0] to [9],
> the
> second page in [10] to [19] and so on:
>
> To display use something like:
> For (int i=pageOffset; Math.min(hitsPerPage + pageOffset,
> collector.topDocs().totalhits); i++)
>
> In general, you cannot retrieve a range directly, you can only retrieve the
> top docs. As most people will not go beyond say page 10 when searching, you
> have no memory problem, as scoreDocs will contain at most 100 doc ids.
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
> > -----Original Message-----
> > From: João Silva [mailto:galaio.silva@gmail.com]
> > Sent: Friday, June 19, 2009 2:17 PM
> > To: java-user@lucene.apache.org
> > Subject: Re: Collector Pagination
> >
> > well,
> >
> > i have somthing like that:
> >
> >  int hitsPerPage = 10;
> >             IndexSearcher searcher = new IndexSearcher(this.indexPath);
> >             TopDocCollector collector = new TopDocCollector(hitsPerPage);
> >             Query query = new QueryParser("",
> > this.analizer).parse(DocumentRepositoryEntry.Fields.ID.toString() + ":"
> >                     + id);
> >             searcher.search(query, collector);
> >
> >             ScoreDoc[] hits = collector.topDocs().scoreDocs;
> >
> > i know that the colector have all docs in the query, how do i navigate
> > between the next pages?
> >
> >
> > thanks,
> > Galaio
> >
> >
> >
> > On Fri, Jun 19, 2009 at 12:57 PM, João Silva <galaio.silva@gmail.com>
> > wrote:
> >
> > > Thanks Uwe, I will see that.
> > >
> > > Galaio
> > >
> > >
> > >
> > >
> > > On Fri, Jun 19, 2009 at 12:36 PM, Uwe Schindler <uwe@thetaphi.de>
> wrote:
> > >
> > >> Hallo,
> > >>
> > >> Just retrieve the TopDocs for the first n documents, where n =
> > >> offset+count,
> > >> where offset is the first hit on the page (0-based) and count the
> > number
> > >> per
> > >> page.
> > >> To display the results you would then just start at offset in TopDocs
> > and
> > >> retrieve the stored field from there to offset+count.
> > >>
> > >> Uwe
> > >>
> > >> -----
> > >> Uwe Schindler
> > >> H.-H.-Meier-Allee 63, D-28213 Bremen
> > >> http://www.thetaphi.de
> > >> eMail: uwe@thetaphi.de
> > >>
> > >>
> > >> > -----Original Message-----
> > >> > From: João Silva [mailto:galaio.silva@gmail.com]
> > >> > Sent: Friday, June 19, 2009 12:58 PM
> > >> > To: java-user@lucene.apache.org
> > >> > Subject: Collector Pagination
> > >> >
> > >> > Hi,
> > >> > is there any api form of Hits pagination?
> > >> > for example, if i want to retreve the hits between
> > >> > an interval.
> > >> >
> > >> > --
> > >> > Cumprimentos,
> > >> > João Carlos Galaio da Silva
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > >> For additional commands, e-mail: java-user-help@lucene.apache.org
> > >>
> > >>
> > >
> > >
> > > --
> > > Cumprimentos,
> > > João Carlos Galaio da Silva
> > >
> >
> >
> >
> > --
> > Cumprimentos,
> > João Carlos Galaio da Silva
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
Cumprimentos,
João Carlos Galaio da Silva

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