lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From saisantoshi <>
Subject TopDocCollector vs TopScoreDocCollector (semantics changed in 4.0, not backward comptabile)
Date Wed, 23 Jan 2013 23:19:10 GMT
Our current search implementation (based on 2.4.0) uses a collector extending
the TopDocCollector class

public class MyHitCollector extends TopDocsCollector {

    private IndexReader indexReader;
    private CustomFilter customFilter;

    public MyHitCollector (IndexReader indexReader, int numberOfHits,
CustomFilter filter) {
    *    super(numberOfHits);*
        this.indexReader = indexReader;
        this.nodeFilter = filter();

    *public void collect(int doc, float score) {*
        try {
            if (score > 0.0f) {
                // do something
                    super.collect(doc, score);
        } catch (Exception e) {

//Using the collector
             MyHitCollector collector;
             IndexSearcher searcher= new IndexSearcher(reader);
               try {
                   collector = new MyHitCollector(reader, maximumHits,
          , null, collector);
                } finally {

                TopDocs docs = collector.topDocs();

Now in 4.0, the TopDocCollector is removed and the suggested class is to use
TopScoreDocCollector (for faster performance).. I don't see the following
signatures available in the newer class thus breaking the backward

public collect(int doc, float score).   //I think this is no longer there.
 super(numberOfHits)  .  //The constructor for this is also been removed in
4.0.. This used to be in 2.4

This looks to be me backward compatibility is broken and there is no proper
documentation as well.

Could someone suggest any alternative here? Any collector that we can use to
be backward compatible?

Thanks and appreciate your help.


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

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

View raw message