From b4467c7d1f9cf2987626f132bce36a5c2c0f190d Mon Sep 17 00:00:00 2001 From: kimchy Date: Wed, 19 Jan 2011 22:59:28 +0200 Subject: [PATCH] use caching scorer when there are multiple collectors, so if they call score as well, it will not be computed again --- .../java/org/elasticsearch/common/lucene/MultiCollector.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/MultiCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/MultiCollector.java index 69b108ad013..aa42a76e4cd 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/MultiCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/MultiCollector.java @@ -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);