summaryrefslogtreecommitdiff
path: root/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java
diff options
context:
space:
mode:
authorSimon Willnauer <simon.willnauer@elasticsearch.com>2016-10-11 15:30:38 +0200
committerGitHub <noreply@github.com>2016-10-11 15:30:38 +0200
commitc98e3f60f78fb47ae7482d96952f2dbabd1d6d49 (patch)
treee8ed1c07eeee9d3e48309da4f71b38ba2cfaa454 /core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java
parent3528a514e2c4135dd216de92bd34c38d8a180173 (diff)
Ensure source filtering automatons are only compiled once (#20857)
This change adds a overloaded `XContentMapValues#filter` method that returns a function enclosing the compiled automatons that can be reused across filter calls. This for instance prevents compiling automatons over and over again when hits are filtered or in the SourceFieldMapper for each document. Closes #20839
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.java41
1 files changed, 21 insertions, 20 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 3f2b4c4462..98e2833903 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
@@ -107,26 +107,27 @@ public class TopHitsTests extends BaseAggregationTestCase<TopHitsAggregationBuil
excludes[i] = randomAsciiOfLengthBetween(5, 20);
}
switch (branch) {
- case 0:
- fetchSourceContext = new FetchSourceContext(randomBoolean());
- break;
- case 1:
- fetchSourceContext = new FetchSourceContext(includes, excludes);
- break;
- case 2:
- fetchSourceContext = new FetchSourceContext(randomAsciiOfLengthBetween(5, 20), randomAsciiOfLengthBetween(5, 20));
- break;
- case 3:
- fetchSourceContext = new FetchSourceContext(true, includes, excludes);
- break;
- case 4:
- fetchSourceContext = new FetchSourceContext(includes);
- break;
- case 5:
- fetchSourceContext = new FetchSourceContext(randomAsciiOfLengthBetween(5, 20));
- break;
- default:
- throw new IllegalStateException();
+ case 0:
+ fetchSourceContext = new FetchSourceContext(randomBoolean());
+ break;
+ case 1:
+ fetchSourceContext = new FetchSourceContext(true, includes, excludes);
+ break;
+ case 2:
+ fetchSourceContext = new FetchSourceContext(true, new String[]{randomAsciiOfLengthBetween(5, 20)},
+ new String[]{randomAsciiOfLengthBetween(5, 20)});
+ break;
+ case 3:
+ fetchSourceContext = new FetchSourceContext(true, includes, excludes);
+ break;
+ case 4:
+ fetchSourceContext = new FetchSourceContext(true, includes, null);
+ break;
+ case 5:
+ fetchSourceContext = new FetchSourceContext(true, new String[] {randomAsciiOfLengthBetween(5, 20)}, null);
+ break;
+ default:
+ throw new IllegalStateException();
}
factory.fetchSource(fetchSourceContext);
}