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 <saisantosh...@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-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to