supported field type tests for max agg (#53701)

Adds test hooks for testing supported ValuesSource types for the max
aggregation
This commit is contained in:
Andy Bristol 2020-04-01 15:24:53 -07:00 committed by GitHub
parent 5d0351ea00
commit ec76e7306e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -71,7 +71,9 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator;
import org.elasticsearch.search.aggregations.support.AggregationInspectionHelper; 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.ValueType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
import org.elasticsearch.search.lookup.LeafDocLookup; import org.elasticsearch.search.lookup.LeafDocLookup;
import java.io.IOException; import java.io.IOException;
@ -89,6 +91,7 @@ import java.util.function.Supplier;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import static java.util.Collections.singleton; import static java.util.Collections.singleton;
import static java.util.Collections.singletonList;
import static org.elasticsearch.index.query.QueryBuilders.termQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -158,6 +161,17 @@ public class MaxAggregatorTests extends AggregatorTestCase {
return new ScriptService(Settings.EMPTY, engines, ScriptModule.CORE_CONTEXTS); 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 { public void testNoDocs() throws IOException {
testCase(new MatchAllDocsQuery(), iw -> { testCase(new MatchAllDocsQuery(), iw -> {
// Intentionally not writing any docs // Intentionally not writing any docs