lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From saisantoshi <>
Subject Extending TopScoreDocCollector to write a custom collector
Date Thu, 24 Jan 2013 05:33:19 GMT
I would like to write a custom collector ( similar to the one which is inside
the source of TopScoreDocCollector  like InOrderTopScoreDocCollector). The
reason for extending this is because InOrderTopScoreDocCollector and 
OutOfOrderTopScoreDocCollector are private to the class and I really wanted
to override the collect(int doc) method to have some custom logic
incorporated. Could someone please let me know if this approach would work
fine? or does have any issues?

Here is what I am thinking:

public class MyCollector extends TopScoreDocCollector {
    public MyCollector (int numHits) {
    public void collect(int doc) throws IOException {
      float score = scorer.score();
       // Add a check here
      if(score < 0.0f) {
      // remaining code

    public boolean acceptsDocsOutOfOrder() {
      return true;

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