summaryrefslogtreecommitdiff
path: root/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java
diff options
context:
space:
mode:
authorChristoph Büscher <christoph@elastic.co>2016-03-29 18:45:07 +0200
committerChristoph Büscher <christoph@elastic.co>2016-04-15 17:13:01 +0200
commitfbd558382d0bb96acb7986f48297c645d1a70c41 (patch)
treef2071331ed3a5563426beb8f05250ec95d58bf99 /core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java
parent068df5f8aa5642432c77962768b17046a86ddbc4 (diff)
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.
Diffstat (limited to 'core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java')
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java4
1 files changed, 1 insertions, 3 deletions
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<TopHitsAggregatorBuild
"}";
try {
XContentParser parser = XContentFactory.xContent(source).createParser(source);
- QueryParseContext parseContext = new QueryParseContext(queriesRegistry);
- parseContext.reset(parser);
- parseContext.parseFieldMatcher(parseFieldMatcher);
+ QueryParseContext parseContext = new QueryParseContext(queriesRegistry, parser, parseFieldMatcher);
assertSame(XContentParser.Token.START_OBJECT, parser.nextToken());
aggParsers.parseAggregators(parseContext);
fail();