From 07090b8ee86b7259c684d5523594899ec928ea09 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 30 Jun 2015 00:32:09 +0200 Subject: [PATCH] percolator: The query parse context should be fetched from the IndexQueryParseService instead of maintaining a thread local cache in the PercolatorQueriesRegistry. Before PercolatorQueriesRegistry had its own cache, because all the queries had to forcefully opt out of caching. Nowadays in master small segments are never cached by the query cache, so the reason for the dedicated cache is no longer valid. --- .../index/percolator/PercolatorQueriesRegistry.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/percolator/PercolatorQueriesRegistry.java b/core/src/main/java/org/elasticsearch/index/percolator/PercolatorQueriesRegistry.java index 43193b47aea..b7488bf9fe6 100644 --- a/core/src/main/java/org/elasticsearch/index/percolator/PercolatorQueriesRegistry.java +++ b/core/src/main/java/org/elasticsearch/index/percolator/PercolatorQueriesRegistry.java @@ -23,7 +23,6 @@ import org.apache.lucene.index.Term; import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.CloseableThreadLocal; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; @@ -85,13 +84,6 @@ public class PercolatorQueriesRegistry extends AbstractIndexShardComponent imple private boolean mapUnmappedFieldsAsString; - private CloseableThreadLocal cache = new CloseableThreadLocal() { - @Override - protected QueryParseContext initialValue() { - return new QueryParseContext(shardId.index(), queryParserService); - } - }; - public PercolatorQueriesRegistry(ShardId shardId, @IndexSettings Settings indexSettings, IndexQueryParserService queryParserService, ShardIndexingService indexingService, IndicesLifecycle indicesLifecycle, MapperService mapperService, IndexFieldDataService indexFieldDataService, ShardPercolateService shardPercolateService) { @@ -197,7 +189,7 @@ public class PercolatorQueriesRegistry extends AbstractIndexShardComponent imple if (type != null) { QueryParseContext.setTypesWithPrevious(new String[]{type}); } - QueryParseContext context = cache.get(); + QueryParseContext context = queryParserService.getParseContext(); try { context.reset(parser); // This means that fields in the query need to exist in the mapping prior to registering this query