lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zhang, Lisheng" <Lisheng.Zh...@broadvision.com>
Subject RE: How to avoid score calculation completely?
Date Thu, 24 May 2007 16:25:27 GMT
Hi, Thanks for helps!

Yes, along the line you mentioned we can reduce the amount
of calculation, but we still need to loop through to count
all docs, so time may still be O(n), I am wondering if we
can avoid the loop to get count directly?

Best regards, Lisheng

-----Original Message-----
From: Michael McCandless [mailto:lucene@mikemccandless.com]
Sent: Thursday, May 24, 2007 7:38 AM
To: java-user@lucene.apache.org
Subject: Re: How to avoid score calculation completely?



"Yonik Seeley" <yonik@apache.org> wrote:
> On 5/24/07, Ramana Jelda <ramana.jelda@ciao-group.com> wrote:
> > But I also see importance of ignoring score calculation.
> >
> > If you put it aside performance gain, is there any possibility to completely
> > ignore scoring calculation?
> 
> Yes, for unsorted results use a hit collector and no sorting will be
> done by score (or anything else).
> 
> You can also ignore the score by simply sorting on other fields.

I *think* something close to this would allow you to count the number
of docs matching a query without scoring:

  Scorer s = query.weight(searcher).scorer(reader);
  int count = 0;
  while(s.next()) {
    count++;
  }

I'm not certain that avoids all scoring work but at least for some of
the scorers it should save some CPU time; I'm not sure how much.  Also
note that the TopDocCollector (used by default if you don't provide
your own collector) does not count docs that have score <= 0.0, so the
above code fragment would overcount in such cases.

Mike

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

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


Mime
View raw message