Skip to content

Commit ec76e73

Browse files
supported field type tests for max agg (#53701)
Adds test hooks for testing supported ValuesSource types for the max aggregation
1 parent 5d0351e commit ec76e73

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

server/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxAggregatorTests.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@
7171
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
7272
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator;
7373
import org.elasticsearch.search.aggregations.support.AggregationInspectionHelper;
74+
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
7475
import org.elasticsearch.search.aggregations.support.ValueType;
76+
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
7577
import org.elasticsearch.search.lookup.LeafDocLookup;
7678

7779
import java.io.IOException;
@@ -89,6 +91,7 @@
8991

9092
import static java.util.Collections.emptyList;
9193
import static java.util.Collections.singleton;
94+
import static java.util.Collections.singletonList;
9295
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
9396
import static org.hamcrest.Matchers.equalTo;
9497

@@ -158,6 +161,17 @@ protected ScriptService getMockScriptService() {
158161
return new ScriptService(Settings.EMPTY, engines, ScriptModule.CORE_CONTEXTS);
159162
}
160163

164+
@Override
165+
protected List<ValuesSourceType> getSupportedValuesSourceTypes() {
166+
return singletonList(CoreValuesSourceType.NUMERIC);
167+
}
168+
169+
@Override
170+
protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldType, String fieldName) {
171+
return new MaxAggregationBuilder("_name")
172+
.field(fieldName);
173+
}
174+
161175
public void testNoDocs() throws IOException {
162176
testCase(new MatchAllDocsQuery(), iw -> {
163177
// Intentionally not writing any docs

0 commit comments

Comments
 (0)