From fbd558382d0bb96acb7986f48297c645d1a70c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Tue, 29 Mar 2016 18:45:07 +0200 Subject: Clean up QueryParseContext and don't hold it inside QueryRewrite/ShardContext This change cleans up a few things in QueryParseContext and QueryShardContext that make it hard to reason about the state of these context objects and are thus error prone and should be simplified. Currently the parser that used in QueryParseContext can be set and reset any time from the outside, which makes reasoning about it hard. This change makes the parser a mandatory constructor argument removes ability to later set a different ParseFieldMatcher. If none is provided at construction time, the one set inside the parser is used. If a ParseFieldMatcher is specified at construction time, it is implicitely set on the parser that is beeing used. The ParseFieldMatcher is only kept inside the parser. Also currently the QueryShardContext historically holds an inner QueryParseContext (in the super class QueryRewriteContext), that is mainly used to hold the parser and parseFieldMatcher. For that reason, the parser can also be reset, which leads to the same problems as above. This change removes the QueryParseContext from QueryRewriteContext and removes the ability to reset or retrieve it from the QueryShardContext. Instead, `QueryRewriteContext#newParseContext(parser)` can be used to create new parse contexts with the given parser from a shard context when needed. --- .../org/elasticsearch/search/aggregations/metrics/TopHitsTests.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java') diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java index bd84853d93..00bb04dde9 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java @@ -173,9 +173,7 @@ public class TopHitsTests extends BaseAggregationTestCase