Skip to content

Instantly share code, notes, and snippets.

@unicolet unicolet/score.java
Created Nov 3, 2017

Embed
What would you like to do?
public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
final float score = score();
final int maxDoc = context.reader().maxDoc();
return new BulkScorer() {
@Override
public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException {
max = Math.min(max, maxDoc);
FakeScorer scorer = new FakeScorer();
scorer.score = score;
collector.setScorer(scorer);
for (int doc = min; doc < max; ++doc) {
scorer.doc = doc;
if (acceptDocs == null || acceptDocs.get(doc)) {
collector.collect(doc);
}
}
return max == maxDoc ? DocIdSetIterator.NO_MORE_DOCS : max;
}
@Override
public long cost() {
return maxDoc;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.