lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tri Cao <tm...@me.com>
Subject Re: Collector is collecting more than the specified hits
Date Fri, 14 Feb 2014 18:47:44 GMT
If I understand correctly, you'd like to shortcut the execution when you reach the desired
number of hits. Unfortunately, I don't think there's a graceful way to do that right now in
Collector. To stop further collecting, you need to throw an IOException (or a subtype of it)
and catch the exception later in your code.

Regards,
Tri

On Feb 14, 2014, at 09:36 AM, saisantoshi <saisantoshi76@gmail.com> wrote:

I am not interested in the scores at all. My requirement is simple, I only
need the first 100 hits or the numHits I specify ( irrespective of there
scores). The collector should stop after collecting the numHits specified.
Is there a way to tell in the collector to stop after collecting the
numHits.

Please correct me if I am wrong. I am trying to do the following.

public void collect(int doc) throws IOException {

if (collector.getTotalHits() <= maxHits ) { // this way, I can stop it
to not collect after the getTotalHits is more than numHits.

delegate.collect(doc); 

}

}

I have to write a separate collector extending the Collector because I am
not able to get the call to getTotalHits() if I am using
PositiveScoresOnlyCollector.





--
View this message in context: http://lucene.472066.n3.nabble.com/Collector-is-collecting-more-than-the-specified-hits-tp4117329p4117441.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

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


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