lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jawahar Lal <j...@chambal.com>
Subject Re: Getting
Date Fri, 24 Dec 2010 11:06:02 GMT
Thanks Umesh

 I want to know more about Filters, how to use that using lucene 3.0.3

Can I get links to learn how/when to use filters.

jawahar

On 24 December 2010 16:25, Umesh Prasad <umesh.iitk@gmail.com> wrote:

> Yes.
>
> Also note that , topdocs.totalhits will always give u total number of hits,
> regardless of the number of score doc u choose to retrieve.
>  topdocs.scoredocs will have min(totalhits, ndocs) docs populated.
>
>
> On Fri, Dec 24, 2010 at 2:48 PM, Jawahar Lal <jlal@chambal.com> wrote:
>
> > ok, I understand.
> >
> > It means, that we have to fetch total no. of docs i.e.
> >
> > Suppose we need to show 100 docs per page
> >
> > Page No.     NDocs       No. of documents to be shown on Page
> > 1                  100            0-99
> > 2                   200           100-199
> > 3                   300            200-299  & so on...
> >
> >
> >
> >
> >
> > On 24 December 2010 12:35, Umesh Prasad <umesh.iitk@gmail.com> wrote:
> >
> > > Hi Jawahar,
> > >   http://search-lucene.com/m/duTpc14AmzV
> > > See Uwe's reply.
> > >
> > >
> > >
> > > Regards
> > > Umesh
> > >
> > > PS: I would use search-lucene.com to 1st check if a solution is posted
> > > already. It is really good.
> > >
> > > ------------------------
> > > QUOTED UWE's reply
> > > ----------------------
> > >
> > > 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.
> > >
> > > ---------------
> > > -------------------
> > >
> > >
> > > On Fri, Dec 24, 2010 at 10:40 AM, Jawahar Lal <jlal@chambal.com>
> wrote:
> > >
> > > > Hi,
> > > >
> > > >  I search for an query. Total searched records are 5000. I only shows
> > 100
> > > > records on one page. So I passed 100 as nDocs.
> > > >
> > > > I write the code in this way.
> > > >
> > > >           IndexSearcher searcher = new
> > IndexSearcher(FSDirectory.open(new
> > > > File(path)));
> > > >
> > > >            Query query = new QueryParser(Version.LUCENE_30, "field1",
> > new
> > > > StandardAnalyzer(Version.LUCENE_30)).parse("query");
> > > >            Query query1 = new QueryParser(Version.LUCENE_30,
> "field2",
> > > new
> > > > StandardAnalyzer(Version.LUCENE_30)).parse("query2");
> > > >            BooleanQuery lucBoolQueryOTHER = new BooleanQuery();
> > > >            lucBoolQueryOTHER.add(query, Occur.MUST);
> > > >            lucBoolQueryOTHER.add(query1, Occur.MUST);
> > > >
> > > >            TopDocs hits=searcher.search(query, null, 100);
> > > >
> > > >            System.err.println("Total searched " + hits.totalHits);
> >>
> > > > 5000
> > > >            System.err.println("Total docs " + hits.scoreDocs.length);
> >  >>
> > > > 100
> > > >
> > > > // The code to print 100 records on first page
> > > >            for(int i=0;i<hits.scoreDocs.length;i++){
> > > >
> > > >
> > > >
> > >
> >
> System.out.println(searcher.doc(hits.scoreDocs[i].doc).getField("filename"));
> > > >            }
> > > >
> > > > it worked fine.
> > > >
> > > > // Now I want to show all next search documents on Second
> Pages...when
> > I
> > > > tried in this way, I got the error.
> > > >            for(int i=100;i<hits.totalHits;i++){
> > > >
> > > >
> > > >
> > >
> >
> System.out.println(searcher.doc(hits.scoreDocs[i].doc).getField("filename"));
> > > >            }
> > > >
> > > >            searcher.close();
> > > >
> > > > java.lang.ArrayIndexOutOfBoundsException: 100
> > > >        at Test.searchIndex(Test.java:96)
> > > >        at Test.main(Test.java:54)
> > > >
> > > > Would need to perform searching again with different parameters to
> > fetch
> > > > next bunch of records ?
> > > >
> > > >
> > > >
> > > >
> > > > Thanks
> > > >
> > >
> > >
> > >
> > > --
> > > ---
> > > Thanks & Regards
> > > Umesh Prasad
> > >
> >
>
>
>
> --
> ---
> Thanks & Regards
> Umesh Prasad
>

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