lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tri Cao <>
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.


On Feb 14, 2014, at 09:36 AM, saisantoshi <> 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

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.




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

View this message in context:
Sent from the Lucene - Java Users mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

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