lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From saisantoshi <saisantosh...@gmail.com>
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,
filter);
                    searcher.search(query, 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
compatibility.

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.

Thanks,
Sai.



--
View this message in context: http://lucene.472066.n3.nabble.com/TopDocCollector-vs-TopScoreDocCollector-semantics-changed-in-4-0-not-backward-comptabile-tp4035806.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
View raw message