From 961df955996eb39d7d35fe8fc76106bbd57ba365 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Tue, 27 Oct 2015 19:14:14 +0100 Subject: [PATCH] Caching Weight wrappers should propagate the BulkScorer. If we don't, then we will use the default bulk scorer, which can be significantly slower in some cases (eg. disjunctions). Related to https://issues.apache.org/jira/browse/LUCENE-6856 --- .../indices/cache/query/IndicesQueryCache.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/main/java/org/elasticsearch/indices/cache/query/IndicesQueryCache.java b/core/src/main/java/org/elasticsearch/indices/cache/query/IndicesQueryCache.java index 30cd6de1233..148f7ba8bdb 100644 --- a/core/src/main/java/org/elasticsearch/indices/cache/query/IndicesQueryCache.java +++ b/core/src/main/java/org/elasticsearch/indices/cache/query/IndicesQueryCache.java @@ -21,6 +21,7 @@ package org.elasticsearch.indices.cache.query; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; +import org.apache.lucene.search.BulkScorer; import org.apache.lucene.search.Explanation; import org.apache.lucene.search.LRUQueryCache; import org.apache.lucene.search.Query; @@ -256,6 +257,12 @@ public class IndicesQueryCache extends AbstractComponent implements QueryCache, shardKeyMap.add(context.reader()); return in.scorer(context); } + + @Override + public BulkScorer bulkScorer(LeafReaderContext context) throws IOException { + shardKeyMap.add(context.reader()); + return in.bulkScorer(context); + } } /** Clear all entries that belong to the given index. */