lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anand Stephen" <an...@sonic.net>
Subject Re: Performance for search when I need all Hits
Date Wed, 11 Feb 2004 07:36:11 GMT
I am trying to convert the using Hits to HitCollector. Does anyone have any
examples?
This is what am trying to do, how do I get the score?

<code>
        Searcher searcher = new IndexSearcher(indexDir);
        IndexReader indexReader = IndexReader.open(indexDir);
        final BitSet bits = new BitSet(indexReader.maxDoc());
        searcher.search(lquery, new HitCollector() {
            public void collect(int doc, float score) {
                bits.set(doc);
            }
        });

        int size = bits.length();

        String[] values = new String[size];
        String type = null;
        ArrayList results = new ArrayList(size);

        for (int i = 0,j = size; i < j; i++) {
            final Document document = searcher.doc(i);
            type = document.get("TYPE");
            //hits.doc(i).get("TYPE");
            values[i] = document.get("ID");
//            System.out.println("score = " + score);
// how do i get the score???
//            resultsMap.put(hits.doc(i).get("ID"), new Float(score));

        }
</code>

thank you,
--a

----- Original Message ----- 
From: "Erik Hatcher" <erik@ehatchersolutions.com>
To: "Lucene Developers List" <lucene-dev@jakarta.apache.org>
Sent: Monday, January 19, 2004 9:21 AM
Subject: Re: Performance for search when I need all Hits


> If you need all search results, use a HitCollector rather than Hits.
> Look at the variants of the IndexSearcher.search method.  I suspect you
> will see the speed with the HitCollector match what you see with your
> Hits tricks if not even faster.
>
> Erik
>
>
> On Jan 19, 2004, at 10:35 AM, Hanjo Riege wrote:
>
> > Hi all,
> >
> > i have a question about the performance:
> >
> > if i need all the results (about 2000 Hits) of a search and read them
> > from first to last then it needs about 3000 ms.
> >
> > After a short look at the method Hits.getMoreDocs(int i) i decided to
> > read the last doc first. Now it needs only 1000 ms to read them all.
> >
> > It seems that the Method is not optimized for getting all the results.
> >
> > Is this a point for improvement or do i miss something?
> >
> > regards
> >
> > Hanjo
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message