use caching scorer when there are multiple collectors, so if they call score as well, it will not be computed again

This commit is contained in:
kimchy 2011-01-19 22:59:28 +02:00
parent 7359f7983f
commit b4467c7d1f
1 changed files with 4 additions and 0 deletions

View File

@ -21,6 +21,7 @@ package org.elasticsearch.common.lucene;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.ScoreCachingWrappingScorer;
import org.apache.lucene.search.Scorer;
import java.io.IOException;
@ -40,6 +41,9 @@ public class MultiCollector extends Collector {
}
@Override public void setScorer(Scorer scorer) throws IOException {
if (collectors.length > 0) {
scorer = new ScoreCachingWrappingScorer(scorer);
}
collector.setScorer(scorer);
for (Collector collector : collectors) {
collector.setScorer(scorer);