Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmute testSupportedFieldTypes, fix Percentiles/Ranks/Terms tests #52734

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PercentilesAggregatorFactory extends ValuesSourceAggregatorFactory {

static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
valuesSourceRegistry.register(PercentilesAggregationBuilder.NAME,
List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.HISTOGRAM),
List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.HISTOGRAM, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
new PercentilesAggregatorSupplier() {
@Override
public Aggregator build(String name, ValuesSource valuesSource, SearchContext context, Aggregator parent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldTy
@Override
protected List<ValuesSourceType> getSupportedValuesSourceTypes() {
return List.of(CoreValuesSourceType.NUMERIC,
CoreValuesSourceType.BYTES);
CoreValuesSourceType.BYTES,
CoreValuesSourceType.IP,
CoreValuesSourceType.DATE,
CoreValuesSourceType.BOOLEAN);
}

public void testGlobalOrdinalsExecutionHint() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldTy

@Override
protected List<ValuesSourceType> getSupportedValuesSourceTypes() {
return List.of(CoreValuesSourceType.NUMERIC);
return List.of(CoreValuesSourceType.NUMERIC,
CoreValuesSourceType.DATE,
CoreValuesSourceType.BOOLEAN);
}

public void testEmpty() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldTy

@Override
protected List<ValuesSourceType> getSupportedValuesSourceTypes() {
return List.of(CoreValuesSourceType.NUMERIC);
return List.of(CoreValuesSourceType.NUMERIC,
CoreValuesSourceType.DATE,
CoreValuesSourceType.BOOLEAN,
CoreValuesSourceType.HISTOGRAM);
}

public void testNoDocs() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldTy

@Override
protected List<ValuesSourceType> getSupportedValuesSourceTypes() {
return List.of(CoreValuesSourceType.NUMERIC);
return List.of(CoreValuesSourceType.NUMERIC,
CoreValuesSourceType.DATE,
CoreValuesSourceType.BOOLEAN);
}

public void testEmpty() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldTy

@Override
protected List<ValuesSourceType> getSupportedValuesSourceTypes() {
return List.of(CoreValuesSourceType.NUMERIC);
return List.of(CoreValuesSourceType.NUMERIC,
CoreValuesSourceType.DATE,
CoreValuesSourceType.BOOLEAN,
CoreValuesSourceType.HISTOGRAM);
}

public void testNoDocs() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,12 @@
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
import org.elasticsearch.index.fielddata.IndexFieldDataService;
import org.elasticsearch.index.mapper.BinaryFieldMapper;
import org.elasticsearch.index.mapper.BooleanFieldMapper;
import org.elasticsearch.index.mapper.CompletionFieldMapper;
import org.elasticsearch.index.mapper.ContentPath;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.FieldAliasMapper;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.GeoShapeFieldMapper;
import org.elasticsearch.index.mapper.IpFieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.Mapper;
import org.elasticsearch.index.mapper.Mapper.BuilderContext;
Expand Down Expand Up @@ -617,7 +614,6 @@ protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldTy
*
* Exception types/messages are not currently checked, just presence/absence of an exception.
*/
@AwaitsFix(bugUrl = "Muted until we can tweak Date/IP/Boolean")
public final void testSupportedFieldTypes() throws IOException {
MapperRegistry mapperRegistry = new IndicesModule(Collections.emptyList()).getMapperRegistry();
Settings settings = Settings.builder().put("index.version.created", Version.CURRENT.id).build();
Expand Down Expand Up @@ -689,12 +685,7 @@ private void writeTestDoc(MappedFieldType fieldType, String fieldName, RandomInd
ValuesSourceType vst = fieldType.getValuesSourceType();

if (vst.equals(CoreValuesSourceType.NUMERIC)) {
// TODO note: once VS refactor adds DATE/BOOLEAN, this conditional will go away
if (typeName.equals(DateFieldMapper.CONTENT_TYPE) || typeName.equals(DateFieldMapper.DATE_NANOS_CONTENT_TYPE)) {
iw.addDocument(singleton(new SortedNumericDocValuesField(fieldName, randomNonNegativeLong())));
} else if (typeName.equals(BooleanFieldMapper.CONTENT_TYPE)) {
iw.addDocument(singleton(new SortedNumericDocValuesField(fieldName, randomBoolean() ? 0 : 1)));
} else if (typeName.equals(NumberFieldMapper.NumberType.DOUBLE.typeName())) {
if (typeName.equals(NumberFieldMapper.NumberType.DOUBLE.typeName())) {
long encoded = NumericUtils.doubleToSortableLong(Math.abs(randomDouble()));
iw.addDocument(singleton(new SortedNumericDocValuesField(fieldName, encoded)));
} else if (typeName.equals(NumberFieldMapper.NumberType.FLOAT.typeName())) {
Expand All @@ -709,13 +700,16 @@ private void writeTestDoc(MappedFieldType fieldType, String fieldName, RandomInd
} else if (vst.equals(CoreValuesSourceType.BYTES)) {
if (typeName.equals(BinaryFieldMapper.CONTENT_TYPE)) {
iw.addDocument(singleton(new BinaryFieldMapper.CustomBinaryDocValuesField(fieldName, new BytesRef("a").bytes)));
} else if (typeName.equals(IpFieldMapper.CONTENT_TYPE)) {
// TODO note: once VS refactor adds IP, this conditional will go away
boolean v4 = randomBoolean();
iw.addDocument(singleton(new SortedSetDocValuesField(fieldName, new BytesRef(InetAddressPoint.encode(randomIp(v4))))));
} else {
iw.addDocument(singleton(new SortedSetDocValuesField(fieldName, new BytesRef("a"))));
}
} else if (vst.equals(CoreValuesSourceType.DATE)) {
iw.addDocument(singleton(new SortedNumericDocValuesField(fieldName, randomNonNegativeLong())));
} else if (vst.equals(CoreValuesSourceType.BOOLEAN)) {
iw.addDocument(singleton(new SortedNumericDocValuesField(fieldName, randomBoolean() ? 0 : 1)));
} else if (vst.equals(CoreValuesSourceType.IP)) {
boolean v4 = randomBoolean();
iw.addDocument(singleton(new SortedSetDocValuesField(fieldName, new BytesRef(InetAddressPoint.encode(randomIp(v4))))));
} else if (vst.equals(CoreValuesSourceType.RANGE)) {
Object start;
Object end;
Expand Down