Skip to content

Commit

Permalink
supported field type tests for max agg (elastic#53701)
Browse files Browse the repository at this point in the history
Adds test hooks for testing supported ValuesSource types for the max
aggregation
  • Loading branch information
andyb-elastic authored Mar 18, 2020
1 parent 36d8d84 commit 73d2add
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator;
import org.elasticsearch.search.aggregations.support.AggregationInspectionHelper;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValueType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
import org.elasticsearch.search.lookup.LeafDocLookup;

import java.io.IOException;
Expand All @@ -89,6 +91,7 @@

import static java.util.Collections.emptyList;
import static java.util.Collections.singleton;
import static java.util.Collections.singletonList;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.hamcrest.Matchers.equalTo;

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

@Override
protected List<ValuesSourceType> getSupportedValuesSourceTypes() {
return singletonList(CoreValuesSourceType.NUMERIC);
}

@Override
protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldType, String fieldName) {
return new MaxAggregationBuilder("_name")
.field(fieldName);
}

public void testNoDocs() throws IOException {
testCase(new MatchAllDocsQuery(), iw -> {
// Intentionally not writing any docs
Expand Down

0 comments on commit 73d2add

Please sign in to comment.