lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: Short circuiting Collector
Date Thu, 21 Jul 2011 09:49:55 GMT
Hi,

The reason is that some scorers passed into setScorer are "fake" scorers
that only implement the "score()" method (depends on the type of
BooleanQuery scorer used for result collection and if the scorer actively
collects the results (happens of top-level-queries).
In general to early exit collection the easiest is to throw a
RuntimeException subclass (this is what TimeLimitingCollector does, see java
file in Lucene source code).

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: Chris Bamford [mailto:chris.bamford@talktalk.net]
> Sent: Thursday, July 21, 2011 11:44 AM
> To: java-user@lucene.apache.org
> Subject: Re: Short circuiting Collector
> 
> 
>  Hi Simon,
> 
> 
> 
> scorer.advance(Scorer.NO_MORE_DOCS);
> 
>  Hmm... doesn't seem to work :-(  I tried to call it in collect() and
> setNextReader() - still loops to the end of the matched doc set.
> What have I missed?
> 
> Thanks
> 
> - Chris
> 
> 
> 
> 
> 
> 
> 
> 
> -----Original Message-----
> From: Simon Willnauer <simon.willnauer@googlemail.com>
> To: java-user@lucene.apache.org
> Sent: Wed, 20 Jul 2011 22:07
> Subject: Re: Short circuiting Collector
> 
> 
> you can advance the scorer to NO_MORE_DOCS if you have collected
> enough documents this will stop the loop.
> 
> scorer.advance(Scorer.NO_MORE_DOCS);
> 
> simon
> 
> On Wed, Jul 20, 2011 at 6:53 PM, Devon H. O'Dell <devon.odell@gmail.com>
> wrote:
> > 2011/7/20 Chris Bamford <chris.bamford@talktalk.net>:
> >> Hi there,
> >>
> >> I have my own Collector implementation which I use for searching,
> >> something
> like this skeleton:
> >
> > [snip]
> >
> >> Question: is there a way to prevent collect() being called after it
> >> has
> collected its quota  (i.e. when collecting becomes false)?  On large
datasets
> this would save a lot of time.
> >> In this scenario I have no need for sort / ordering etc.
> >
> > I'd be interested in knowing this as well. My application has the
> > ability to limit the number of results returned, and I've "solved"
> > this problem by simply checking whether the number of collected
> > results exceeds this threshold and simply returning if it has. This
> > seems fast enough, but it would be nice to be able to notify the
> > caller that I don't want any more documents somehow.
> >
> > I was personally unable to find any other workaround for this, and
> > perhaps my hackish solution will work for you (if you're not already
> > doing this). But indeed on searches returning several million records,
> > it's kind of silly to keep spinning.
> >
> > Kind regards,
> >
> > Devon H. O'Dell
> >
> >> Thanks.
> >>
> >> - Chris
> >>
> >
> > ---------------------------------------------------------------------
> > 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
> 
> 
> 


---------------------------------------------------------------------
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