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 <[email protected]> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]