The problem with the below collector is the collect method is not stopping
after the numHits count has reached. Is there a way to stop the collector
collecting the docs after it has reached the numHits specified.

For example:
* TopScoreDocCollector topScore = TopScoreDocCollector.create(numHits,
true); *
// TopScoreDocCollector topScore = TopScoreDocCollector.create(30, true); 

I would except the below collector to pause/exit out after it has collected
the specified numHits ( in this case it's 30). But what's happening here is
the collector is collecting all the docs and thereby causing delay in
searches. Can we configure the collect method below to collect/stop after it
has reached numHits specified? PLease let me know if there any issue with
the collector below?

public class MyCollector extends PositiveScoresOnlyCollector  { 

    private IndexReader indexReader; 
      
    
    public MyCollector (IndexReader indexReader,PositiveScoresOnlyCollector
topScore) { 
        super(topScore); 
        this.indexReader = indexReader; 
    } 

    @Override 
    public void collect(int doc) { 
        try { 
               //Custom Logic 
                    super.collect(doc); 
           } 
            
        } catch (Exception e) { 
          
        } 
    } 



//Usage: 

MyCollector collector; 
                TopScoreDocCollector topScore =
TopScoreDocCollector.create(numHits, true); 
                IndexSearcher searcher = new IndexSearcher(reader); 
                try { 
                    collector = new MyCollector(indexReader, new
PositiveScoresOnlyCollector(topScore)); 
                    searcher.search(query, (Filter) null, collector); 
                } finally { 
                  
                } 

Thanks,
Sai.



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Collector-is-collecting-more-than-the-specified-hits-tp4117329.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