Here is the way I implemented a collector class. Appreciate if you could let
me know of any issues..
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(hits, true);
IndexSearcher searcher = new IndexSearcher(reader);
try {
collector = new MyCollector(indexReader, new
PositiveScoresOnlyCollector(topScore));
searcher.search(query, (Filter) null, collector);
} finally {
}
TopDocs hitDocs = topScore.topDocs();
--
View this message in context:
http://lucene.472066.n3.nabble.com/Extending-TopScoreDocCollector-to-write-a-custom-collector-tp4035861p4035869.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]