hey,

you don't need to set the indexreader in the constructor. An
AtomicReader is passed in for each segment to
Collector#setNextReader(AtomicReaderContext)
If you want to use a given collector and extend it with some custom
code in collect I would likely write a delegate Collector like this:

public class DelegatingCollector extends Collector {

  private final Collector delegate;

  public DelegatingCollector(Collector delegate) {
    this.delegate = delegate;
  }

 public Collector getDelegate() {
    return delegate;
  }

  @Override
  public void setScorer(Scorer scorer) throws IOException {
    delegate.setScorer(scorer);
  }

  @Override
  public void collect(int doc) throws IOException {
    // ADD YOUR CUSTOM LOGIC HERE
    delegate.collect(doc);
  }

  @Override
  public void setNextReader(AtomicReaderContext context) throws IOException {
    // THIS IS WHERE YOU GET THE READER --> context.reader()
    delegate.setNextReader(context);
  }

  @Override
  public boolean acceptsDocsOutOfOrder() {
    return delegate.acceptsDocsOutOfOrder();
  }
}

maybe this is easier for you? then you can simply call
TopScoreDocCollector.create(int numHits, boolean docsScoredInOrder);
and use the specialized collector for your settings in the delegate?

simon

On Thu, Jan 24, 2013 at 11:37 PM, saisantoshi <saisantosh...@gmail.com> wrote:
> Can someone please help us here to validate the above?
>
> Thanks,
> Sai.
>
>
>
> --
> View this message in context: 
> http://lucene.472066.n3.nabble.com/TopDocCollector-vs-TopScoreDocCollector-semantics-changed-in-4-0-not-backward-comptabile-tp4035806p4036093.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
>

---------------------------------------------------------------------
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