Skip to content

Instantly share code, notes, and snippets.

@unicolet
Created November 3, 2017 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unicolet/c2d794987d68fc4976c45017f639b567 to your computer and use it in GitHub Desktop.
Save unicolet/c2d794987d68fc4976c45017f639b567 to your computer and use it in GitHub Desktop.
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