diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/BinaryValuesSource.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/BinaryValuesSource.java index 44a29e2251b13..3477c203d4887 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/BinaryValuesSource.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/BinaryValuesSource.java @@ -47,10 +47,8 @@ import org.opensearch.index.mapper.StringFieldType; import org.opensearch.search.DocValueFormat; import org.opensearch.search.aggregations.LeafBucketCollector; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import java.io.IOException; -import java.util.Objects; import java.util.function.LongConsumer; /** @@ -70,11 +68,10 @@ class BinaryValuesSource extends SingleDimensionValuesSource { CheckedFunction docValuesFunc, DocValueFormat format, boolean missingBucket, - MissingOrder missingOrder, int size, int reverseMul ) { - super(bigArrays, format, fieldType, missingBucket, missingOrder, size, reverseMul); + super(bigArrays, format, fieldType, missingBucket, size, reverseMul); this.breakerConsumer = breakerConsumer; this.docValuesFunc = docValuesFunc; this.values = bigArrays.newObjectArray(Math.min(size, 100)); @@ -104,9 +101,10 @@ void copyCurrent(int slot) { @Override int compare(int from, int to) { if (missingBucket) { - int result = missingOrder.compare(() -> Objects.isNull(values.get(from)), () -> Objects.isNull(values.get(to)), reverseMul); - if (MissingOrder.unknownOrder(result) == false) { - return result; + if (values.get(from) == null) { + return values.get(to) == null ? 0 : -1 * reverseMul; + } else if (values.get(to) == null) { + return reverseMul; } } return compareValues(values.get(from), values.get(to)); @@ -115,9 +113,10 @@ int compare(int from, int to) { @Override int compareCurrent(int slot) { if (missingBucket) { - int result = missingOrder.compare(() -> Objects.isNull(currentValue), () -> Objects.isNull(values.get(slot)), reverseMul); - if (MissingOrder.unknownOrder(result) == false) { - return result; + if (currentValue == null) { + return values.get(slot) == null ? 0 : -1 * reverseMul; + } else if (values.get(slot) == null) { + return reverseMul; } } return compareValues(currentValue, values.get(slot)); @@ -126,9 +125,10 @@ int compareCurrent(int slot) { @Override int compareCurrentWithAfter() { if (missingBucket) { - int result = missingOrder.compare(() -> Objects.isNull(currentValue), () -> Objects.isNull(afterValue), reverseMul); - if (MissingOrder.unknownOrder(result) == false) { - return result; + if (currentValue == null) { + return afterValue == null ? 0 : -1 * reverseMul; + } else if (afterValue == null) { + return reverseMul; } } return compareValues(currentValue, afterValue); diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregator.java index 1d48850bee122..dd399e406177d 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregator.java @@ -70,7 +70,6 @@ import org.opensearch.search.aggregations.MultiBucketCollector; import org.opensearch.search.aggregations.MultiBucketConsumerService; import org.opensearch.search.aggregations.bucket.BucketsAggregator; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import org.opensearch.search.internal.SearchContext; import org.opensearch.search.searchafter.SearchAfterBuilder; import org.opensearch.search.sort.SortAndFormats; @@ -90,7 +89,6 @@ final class CompositeAggregator extends BucketsAggregator { private final int size; private final List sourceNames; private final int[] reverseMuls; - private final MissingOrder[] missingOrders; private final List formats; private final CompositeKey rawAfterKey; @@ -119,7 +117,6 @@ final class CompositeAggregator extends BucketsAggregator { this.size = size; this.sourceNames = Arrays.stream(sourceConfigs).map(CompositeValuesSourceConfig::name).collect(Collectors.toList()); this.reverseMuls = Arrays.stream(sourceConfigs).mapToInt(CompositeValuesSourceConfig::reverseMul).toArray(); - this.missingOrders = Arrays.stream(sourceConfigs).map(CompositeValuesSourceConfig::missingOrder).toArray(MissingOrder[]::new); this.formats = Arrays.stream(sourceConfigs).map(CompositeValuesSourceConfig::format).collect(Collectors.toList()); this.sources = new SingleDimensionValuesSource[sourceConfigs.length]; // check that the provided size is not greater than the search.max_buckets setting @@ -192,15 +189,7 @@ public InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws I CompositeKey key = queue.toCompositeKey(slot); InternalAggregations aggs = subAggsForBuckets[slot]; int docCount = queue.getDocCount(slot); - buckets[queue.size()] = new InternalComposite.InternalBucket( - sourceNames, - formats, - key, - reverseMuls, - missingOrders, - docCount, - aggs - ); + buckets[queue.size()] = new InternalComposite.InternalBucket(sourceNames, formats, key, reverseMuls, docCount, aggs); } CompositeKey lastBucket = num > 0 ? buckets[num - 1].getRawKey() : null; return new InternalAggregation[] { @@ -212,7 +201,6 @@ public InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws I Arrays.asList(buckets), lastBucket, reverseMuls, - missingOrders, earlyTerminated, metadata() ) }; @@ -220,18 +208,7 @@ public InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws I @Override public InternalAggregation buildEmptyAggregation() { - return new InternalComposite( - name, - size, - sourceNames, - formats, - Collections.emptyList(), - null, - reverseMuls, - missingOrders, - false, - metadata() - ); + return new InternalComposite(name, size, sourceNames, formats, Collections.emptyList(), null, reverseMuls, false, metadata()); } private void finishLeaf() { diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java index f4426c5772dc9..4c0a5c9ab515a 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java @@ -33,7 +33,6 @@ package org.opensearch.search.aggregations.bucket.composite; import org.opensearch.LegacyESVersion; -import org.opensearch.Version; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; @@ -41,7 +40,6 @@ import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.index.query.QueryShardContext; import org.opensearch.script.Script; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import org.opensearch.search.aggregations.support.ValueType; import org.opensearch.search.aggregations.support.ValuesSource; import org.opensearch.search.aggregations.support.ValuesSourceConfig; @@ -52,8 +50,6 @@ import java.time.ZoneId; import java.util.Objects; -import static org.opensearch.search.aggregations.bucket.missing.MissingOrder.fromString; - /** * A {@link ValuesSource} builder for {@link CompositeAggregationBuilder} */ @@ -64,7 +60,6 @@ public abstract class CompositeValuesSourceBuilder createValuesSource( private final DocValueFormat format; private final int reverseMul; private final boolean missingBucket; - private final MissingOrder missingOrder; private final boolean hasScript; private final SingleDimensionValuesSourceProvider singleDimensionValuesSourceProvider; @@ -85,7 +83,6 @@ SingleDimensionValuesSource createValuesSource( DocValueFormat format, SortOrder order, boolean missingBucket, - MissingOrder missingOrder, boolean hasScript, SingleDimensionValuesSourceProvider singleDimensionValuesSourceProvider ) { @@ -97,7 +94,6 @@ SingleDimensionValuesSource createValuesSource( this.missingBucket = missingBucket; this.hasScript = hasScript; this.singleDimensionValuesSourceProvider = singleDimensionValuesSourceProvider; - this.missingOrder = missingOrder; } /** @@ -136,13 +132,6 @@ boolean missingBucket() { return missingBucket; } - /** - * Return the {@link MissingOrder} for the config. - */ - MissingOrder missingOrder() { - return missingOrder; - } - /** * Returns true if the source contains a script that can change the value. */ diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesSourceParserHelper.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesSourceParserHelper.java index c1e64f57c10cc..888b16b348a14 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesSourceParserHelper.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesSourceParserHelper.java @@ -43,7 +43,6 @@ import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentParser; import org.opensearch.script.Script; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import org.opensearch.search.aggregations.support.ValueType; import java.io.IOException; @@ -55,7 +54,6 @@ public class CompositeValuesSourceParserHelper { static , T> void declareValuesSourceFields(AbstractObjectParser objectParser) { objectParser.declareField(VB::field, XContentParser::text, new ParseField("field"), ObjectParser.ValueType.STRING); objectParser.declareBoolean(VB::missingBucket, new ParseField("missing_bucket")); - objectParser.declareString(VB::missingOrder, new ParseField(MissingOrder.NAME)); objectParser.declareField(VB::userValuetypeHint, p -> { ValueType valueType = ValueType.lenientParse(p.text()); diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java index acab1790bfa21..51c014cf71ec1 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java @@ -52,7 +52,6 @@ import org.opensearch.search.aggregations.bucket.histogram.DateIntervalConsumer; import org.opensearch.search.aggregations.bucket.histogram.DateIntervalWrapper; import org.opensearch.search.aggregations.bucket.histogram.Histogram; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import org.opensearch.search.aggregations.support.CoreValuesSourceType; import org.opensearch.search.aggregations.support.ValuesSource; import org.opensearch.search.aggregations.support.ValuesSourceConfig; @@ -82,7 +81,6 @@ CompositeValuesSourceConfig apply( boolean hasScript, // probably redundant with the config, but currently we check this two different ways... String format, boolean missingBucket, - MissingOrder missingOrder, SortOrder order ); } @@ -290,7 +288,7 @@ public static void register(ValuesSourceRegistry.Builder builder) { builder.register( REGISTRY_KEY, org.opensearch.common.collect.List.of(CoreValuesSourceType.DATE, CoreValuesSourceType.NUMERIC), - (valuesSourceConfig, rounding, name, hasScript, format, missingBucket, missingOrder, order) -> { + (valuesSourceConfig, rounding, name, hasScript, format, missingBucket, order) -> { ValuesSource.Numeric numeric = (ValuesSource.Numeric) valuesSourceConfig.getValuesSource(); // TODO once composite is plugged in to the values source registry or at least understands Date values source types use it // here @@ -306,7 +304,6 @@ public static void register(ValuesSourceRegistry.Builder builder) { docValueFormat, order, missingBucket, - missingOrder, hasScript, ( BigArrays bigArrays, @@ -322,7 +319,6 @@ public static void register(ValuesSourceRegistry.Builder builder) { roundingValuesSource::round, compositeValuesSourceConfig.format(), compositeValuesSourceConfig.missingBucket(), - compositeValuesSourceConfig.missingOrder(), size, compositeValuesSourceConfig.reverseMul() ); @@ -343,6 +339,6 @@ protected CompositeValuesSourceConfig innerBuild(QueryShardContext queryShardCon Rounding rounding = dateHistogramInterval.createRounding(timeZone(), offset); return queryShardContext.getValuesSourceRegistry() .getAggregator(REGISTRY_KEY, config) - .apply(config, rounding, name, config.script() != null, format(), missingBucket(), missingOrder(), order()); + .apply(config, rounding, name, config.script() != null, format(), missingBucket(), order()); } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/DoubleValuesSource.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/DoubleValuesSource.java index fb94ff194b950..0af5c2a901093 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/DoubleValuesSource.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/DoubleValuesSource.java @@ -44,7 +44,6 @@ import org.opensearch.index.mapper.MappedFieldType; import org.opensearch.search.DocValueFormat; import org.opensearch.search.aggregations.LeafBucketCollector; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import java.io.IOException; @@ -64,11 +63,10 @@ class DoubleValuesSource extends SingleDimensionValuesSource { CheckedFunction docValuesFunc, DocValueFormat format, boolean missingBucket, - MissingOrder missingOrder, int size, int reverseMul ) { - super(bigArrays, format, fieldType, missingBucket, missingOrder, size, reverseMul); + super(bigArrays, format, fieldType, missingBucket, size, reverseMul); this.docValuesFunc = docValuesFunc; this.bits = missingBucket ? new BitArray(100, bigArrays) : null; this.values = bigArrays.newDoubleArray(Math.min(size, 100), false); @@ -91,9 +89,10 @@ void copyCurrent(int slot) { @Override int compare(int from, int to) { if (missingBucket) { - int result = missingOrder.compare(() -> bits.get(from) == false, () -> bits.get(to) == false, reverseMul); - if (MissingOrder.unknownOrder(result) == false) { - return result; + if (bits.get(from) == false) { + return bits.get(to) ? -1 * reverseMul : 0; + } else if (bits.get(to) == false) { + return reverseMul; } } return compareValues(values.get(from), values.get(to)); @@ -102,9 +101,10 @@ int compare(int from, int to) { @Override int compareCurrent(int slot) { if (missingBucket) { - int result = missingOrder.compare(() -> missingCurrentValue, () -> bits.get(slot) == false, reverseMul); - if (MissingOrder.unknownOrder(result) == false) { - return result; + if (missingCurrentValue) { + return bits.get(slot) ? -1 * reverseMul : 0; + } else if (bits.get(slot) == false) { + return reverseMul; } } return compareValues(currentValue, values.get(slot)); @@ -113,9 +113,10 @@ int compareCurrent(int slot) { @Override int compareCurrentWithAfter() { if (missingBucket) { - int result = missingOrder.compare(() -> missingCurrentValue, () -> afterValue == null, reverseMul); - if (MissingOrder.unknownOrder(result) == false) { - return result; + if (missingCurrentValue) { + return afterValue != null ? -1 * reverseMul : 0; + } else if (afterValue == null) { + return reverseMul; } } return compareValues(currentValue, afterValue); diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GeoTileGridValuesSourceBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GeoTileGridValuesSourceBuilder.java index 5d47a44a26222..b4049568af4a8 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GeoTileGridValuesSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GeoTileGridValuesSourceBuilder.java @@ -49,7 +49,6 @@ import org.opensearch.search.aggregations.bucket.geogrid.CellIdSource; import org.opensearch.search.aggregations.bucket.geogrid.GeoTileGridAggregationBuilder; import org.opensearch.search.aggregations.bucket.geogrid.GeoTileUtils; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import org.opensearch.search.aggregations.support.CoreValuesSourceType; import org.opensearch.search.aggregations.support.ValuesSource; import org.opensearch.search.aggregations.support.ValuesSourceConfig; @@ -73,7 +72,6 @@ CompositeValuesSourceConfig apply( boolean hasScript, // probably redundant with the config, but currently we check this two different ways... String format, boolean missingBucket, - MissingOrder missingOrder, SortOrder order ); } @@ -105,7 +103,7 @@ static void register(ValuesSourceRegistry.Builder builder) { builder.register( REGISTRY_KEY, CoreValuesSourceType.GEOPOINT, - (valuesSourceConfig, precision, boundingBox, name, hasScript, format, missingBucket, missingOrder, order) -> { + (valuesSourceConfig, precision, boundingBox, name, hasScript, format, missingBucket, order) -> { ValuesSource.GeoPoint geoPoint = (ValuesSource.GeoPoint) valuesSourceConfig.getValuesSource(); // is specified in the builder. final MappedFieldType fieldType = valuesSourceConfig.fieldType(); @@ -117,7 +115,6 @@ static void register(ValuesSourceRegistry.Builder builder) { DocValueFormat.GEOTILE, order, missingBucket, - missingOrder, hasScript, ( BigArrays bigArrays, @@ -135,7 +132,6 @@ static void register(ValuesSourceRegistry.Builder builder) { LongUnaryOperator.identity(), compositeValuesSourceConfig.format(), compositeValuesSourceConfig.missingBucket(), - compositeValuesSourceConfig.missingOrder(), size, compositeValuesSourceConfig.reverseMul() ); @@ -224,7 +220,7 @@ protected ValuesSourceType getDefaultValuesSourceType() { protected CompositeValuesSourceConfig innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config) throws IOException { return queryShardContext.getValuesSourceRegistry() .getAggregator(REGISTRY_KEY, config) - .apply(config, precision, geoBoundingBox(), name, script() != null, format(), missingBucket(), missingOrder(), order()); + .apply(config, precision, geoBoundingBox(), name, script() != null, format(), missingBucket(), order()); } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GeoTileValuesSource.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GeoTileValuesSource.java index 2daddc9647f44..7ad38ec1a3b38 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GeoTileValuesSource.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GeoTileValuesSource.java @@ -39,7 +39,6 @@ import org.opensearch.index.mapper.MappedFieldType; import org.opensearch.search.DocValueFormat; import org.opensearch.search.aggregations.bucket.geogrid.GeoTileUtils; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import java.io.IOException; import java.util.function.LongUnaryOperator; @@ -58,11 +57,10 @@ class GeoTileValuesSource extends LongValuesSource { LongUnaryOperator rounding, DocValueFormat format, boolean missingBucket, - MissingOrder missingOrder, int size, int reverseMul ) { - super(bigArrays, fieldType, docValuesFunc, rounding, format, missingBucket, missingOrder, size, reverseMul); + super(bigArrays, fieldType, docValuesFunc, rounding, format, missingBucket, size, reverseMul); } @Override diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GlobalOrdinalValuesSource.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GlobalOrdinalValuesSource.java index b4db4d8dd2a36..8c000f7a6190c 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GlobalOrdinalValuesSource.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GlobalOrdinalValuesSource.java @@ -46,7 +46,6 @@ import org.opensearch.index.mapper.StringFieldType; import org.opensearch.search.DocValueFormat; import org.opensearch.search.aggregations.LeafBucketCollector; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import java.io.IOException; @@ -72,11 +71,10 @@ class GlobalOrdinalValuesSource extends SingleDimensionValuesSource { CheckedFunction docValuesFunc, DocValueFormat format, boolean missingBucket, - MissingOrder missingOrder, int size, int reverseMul ) { - super(bigArrays, format, type, missingBucket, missingOrder, size, reverseMul); + super(bigArrays, format, type, missingBucket, size, reverseMul); this.docValuesFunc = docValuesFunc; this.values = bigArrays.newLongArray(Math.min(size, 100), false); } @@ -89,34 +87,16 @@ void copyCurrent(int slot) { @Override int compare(int from, int to) { - if (missingBucket) { - int result = missingOrder.compare(() -> values.get(from) == -1, () -> values.get(to) == -1, reverseMul); - if (MissingOrder.unknownOrder(result) == false) { - return result; - } - } return Long.compare(values.get(from), values.get(to)) * reverseMul; } @Override int compareCurrent(int slot) { - if (missingBucket) { - int result = missingOrder.compare(() -> currentValue == -1, () -> values.get(slot) == -1, reverseMul); - if (MissingOrder.unknownOrder(result) == false) { - return result; - } - } return Long.compare(currentValue, values.get(slot)) * reverseMul; } @Override int compareCurrentWithAfter() { - if (missingBucket) { - int result = missingOrder.compare(() -> currentValue == -1, () -> afterValueGlobalOrd == -1, reverseMul); - if (MissingOrder.unknownOrder(result) == false) { - return result; - } - } int cmp = Long.compare(currentValue, afterValueGlobalOrd); if (cmp == 0 && isTopValueInsertionPoint) { // the top value is missing in this shard, the comparison is against diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/HistogramValuesSourceBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/HistogramValuesSourceBuilder.java index 1f1ed3b6254ba..f30fde164f9c4 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/HistogramValuesSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/HistogramValuesSourceBuilder.java @@ -42,7 +42,6 @@ import org.opensearch.index.mapper.MappedFieldType; import org.opensearch.index.query.QueryShardContext; import org.opensearch.search.aggregations.bucket.histogram.Histogram; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import org.opensearch.search.aggregations.support.CoreValuesSourceType; import org.opensearch.search.aggregations.support.ValuesSource; import org.opensearch.search.aggregations.support.ValuesSourceConfig; @@ -68,7 +67,6 @@ CompositeValuesSourceConfig apply( boolean hasScript, // probably redundant with the config, but currently we check this two different ways... String format, boolean missingBucket, - MissingOrder missingOrder, SortOrder order ); } @@ -94,7 +92,7 @@ public static void register(ValuesSourceRegistry.Builder builder) { builder.register( REGISTRY_KEY, org.opensearch.common.collect.List.of(CoreValuesSourceType.DATE, CoreValuesSourceType.NUMERIC), - (valuesSourceConfig, interval, name, hasScript, format, missingBucket, missingOrder, order) -> { + (valuesSourceConfig, interval, name, hasScript, format, missingBucket, order) -> { ValuesSource.Numeric numeric = (ValuesSource.Numeric) valuesSourceConfig.getValuesSource(); final HistogramValuesSource vs = new HistogramValuesSource(numeric, interval); final MappedFieldType fieldType = valuesSourceConfig.fieldType(); @@ -105,7 +103,6 @@ public static void register(ValuesSourceRegistry.Builder builder) { valuesSourceConfig.format(), order, missingBucket, - missingOrder, hasScript, ( BigArrays bigArrays, @@ -120,7 +117,6 @@ public static void register(ValuesSourceRegistry.Builder builder) { numericValuesSource::doubleValues, compositeValuesSourceConfig.format(), compositeValuesSourceConfig.missingBucket(), - compositeValuesSourceConfig.missingOrder(), size, compositeValuesSourceConfig.reverseMul() ); @@ -198,6 +194,6 @@ protected ValuesSourceType getDefaultValuesSourceType() { protected CompositeValuesSourceConfig innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config) throws IOException { return queryShardContext.getValuesSourceRegistry() .getAggregator(REGISTRY_KEY, config) - .apply(config, interval, name, script() != null, format(), missingBucket(), missingOrder(), order()); + .apply(config, interval, name, script() != null, format(), missingBucket(), order()); } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/InternalComposite.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/InternalComposite.java index 02d73217fa04c..f23c9feb07ab8 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/InternalComposite.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/InternalComposite.java @@ -34,7 +34,6 @@ import org.apache.lucene.util.BytesRef; import org.opensearch.LegacyESVersion; -import org.opensearch.Version; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.xcontent.XContentBuilder; @@ -44,7 +43,6 @@ import org.opensearch.search.aggregations.InternalAggregations; import org.opensearch.search.aggregations.InternalMultiBucketAggregation; import org.opensearch.search.aggregations.KeyComparable; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import java.io.IOException; import java.util.AbstractMap; @@ -66,7 +64,6 @@ public class InternalComposite extends InternalMultiBucketAggregation buckets; private final CompositeKey afterKey; private final int[] reverseMuls; - private final MissingOrder[] missingOrders; private final List sourceNames; private final List formats; @@ -80,7 +77,6 @@ public class InternalComposite extends InternalMultiBucketAggregation buckets, CompositeKey afterKey, int[] reverseMuls, - MissingOrder[] missingOrders, boolean earlyTerminated, Map metadata ) { @@ -91,7 +87,6 @@ public class InternalComposite extends InternalMultiBucketAggregation new InternalBucket(input, sourceNames, formats, reverseMuls, missingOrders)); + this.buckets = in.readList((input) -> new InternalBucket(input, sourceNames, formats, reverseMuls)); if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { this.afterKey = in.readBoolean() ? new CompositeKey(in) : null; } else { @@ -133,9 +122,6 @@ protected void doWriteTo(StreamOutput out) throws IOException { } } out.writeIntArray(reverseMuls); - if (out.getVersion().onOrAfter(Version.V_1_3_0)) { - out.writeArray((output, order) -> order.writeTo(output), missingOrders); - } out.writeList(buckets); if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { out.writeBoolean(afterKey != null); @@ -143,7 +129,6 @@ protected void doWriteTo(StreamOutput out) throws IOException { afterKey.writeTo(out); } } - if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { out.writeBoolean(earlyTerminated); } @@ -166,18 +151,7 @@ public InternalComposite create(List newBuckets) { * keep the afterKey of the original aggregation in order * to be able to retrieve the next page even if all buckets have been filtered. */ - return new InternalComposite( - name, - size, - sourceNames, - formats, - newBuckets, - afterKey, - reverseMuls, - missingOrders, - earlyTerminated, - getMetadata() - ); + return new InternalComposite(name, size, sourceNames, formats, newBuckets, afterKey, reverseMuls, earlyTerminated, getMetadata()); } @Override @@ -187,7 +161,6 @@ public InternalBucket createBucket(InternalAggregations aggregations, InternalBu prototype.formats, prototype.key, prototype.reverseMuls, - prototype.missingOrders, prototype.docCount, aggregations ); @@ -273,18 +246,7 @@ public InternalAggregation reduce(List aggregations, Reduce lastKey = lastBucket.getRawKey(); } reduceContext.consumeBucketsAndMaybeBreak(result.size()); - return new InternalComposite( - name, - size, - sourceNames, - reducedFormats, - result, - lastKey, - reverseMuls, - missingOrders, - earlyTerminated, - metadata - ); + return new InternalComposite(name, size, sourceNames, reducedFormats, result, lastKey, reverseMuls, earlyTerminated, metadata); } @Override @@ -302,7 +264,7 @@ protected InternalBucket reduceBucket(List buckets, ReduceContex * just whatever formats make sense for *its* index. This can be real * trouble when the index doing the reducing is unmapped. */ List reducedFormats = buckets.get(0).formats; - return new InternalBucket(sourceNames, reducedFormats, buckets.get(0).key, reverseMuls, missingOrders, docCount, aggs); + return new InternalBucket(sourceNames, reducedFormats, buckets.get(0).key, reverseMuls, docCount, aggs); } @Override @@ -315,13 +277,12 @@ public boolean equals(Object obj) { return Objects.equals(size, that.size) && Objects.equals(buckets, that.buckets) && Objects.equals(afterKey, that.afterKey) - && Arrays.equals(reverseMuls, that.reverseMuls) - && Arrays.equals(missingOrders, that.missingOrders); + && Arrays.equals(reverseMuls, that.reverseMuls); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), size, buckets, afterKey, Arrays.hashCode(reverseMuls), Arrays.hashCode(missingOrders)); + return Objects.hash(super.hashCode(), size, buckets, afterKey, Arrays.hashCode(reverseMuls)); } private static class BucketIterator implements Comparable { @@ -351,7 +312,6 @@ public static class InternalBucket extends InternalMultiBucketAggregation.Intern private final long docCount; private final InternalAggregations aggregations; private final transient int[] reverseMuls; - private final transient MissingOrder[] missingOrders; private final transient List sourceNames; private final transient List formats; @@ -360,7 +320,6 @@ public static class InternalBucket extends InternalMultiBucketAggregation.Intern List formats, CompositeKey key, int[] reverseMuls, - MissingOrder[] missingOrders, long docCount, InternalAggregations aggregations ) { @@ -368,23 +327,15 @@ public static class InternalBucket extends InternalMultiBucketAggregation.Intern this.docCount = docCount; this.aggregations = aggregations; this.reverseMuls = reverseMuls; - this.missingOrders = missingOrders; this.sourceNames = sourceNames; this.formats = formats; } - InternalBucket( - StreamInput in, - List sourceNames, - List formats, - int[] reverseMuls, - MissingOrder[] missingOrders - ) throws IOException { + InternalBucket(StreamInput in, List sourceNames, List formats, int[] reverseMuls) throws IOException { this.key = new CompositeKey(in); this.docCount = in.readVLong(); this.aggregations = InternalAggregations.readFrom(in); this.reverseMuls = reverseMuls; - this.missingOrders = missingOrders; this.sourceNames = sourceNames; this.formats = formats; } @@ -460,15 +411,13 @@ List getFormats() { @Override public int compareKey(InternalBucket other) { for (int i = 0; i < key.size(); i++) { - // lambda function require final variable. - final int index = i; - int result = missingOrders[i].compare(() -> key.get(index) == null, () -> other.key.get(index) == null, reverseMuls[i]); - if (MissingOrder.unknownOrder(result) == false) { - if (result == 0) { + if (key.get(i) == null) { + if (other.key.get(i) == null) { continue; - } else { - return result; } + return -1 * reverseMuls[i]; + } else if (other.key.get(i) == null) { + return reverseMuls[i]; } assert key.get(i).getClass() == other.key.get(i).getClass(); @SuppressWarnings("unchecked") diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/LongValuesSource.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/LongValuesSource.java index 0ce147a138a96..e964283e2e362 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/LongValuesSource.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/LongValuesSource.java @@ -54,10 +54,8 @@ import org.opensearch.index.mapper.NumberFieldMapper; import org.opensearch.search.DocValueFormat; import org.opensearch.search.aggregations.LeafBucketCollector; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import java.io.IOException; -import java.util.Objects; import java.util.function.LongUnaryOperator; import java.util.function.ToLongFunction; @@ -81,11 +79,10 @@ class LongValuesSource extends SingleDimensionValuesSource { LongUnaryOperator rounding, DocValueFormat format, boolean missingBucket, - MissingOrder missingOrder, int size, int reverseMul ) { - super(bigArrays, format, fieldType, missingBucket, missingOrder, size, reverseMul); + super(bigArrays, format, fieldType, missingBucket, size, reverseMul); this.bigArrays = bigArrays; this.docValuesFunc = docValuesFunc; this.rounding = rounding; @@ -110,9 +107,10 @@ void copyCurrent(int slot) { @Override int compare(int from, int to) { if (missingBucket) { - int result = missingOrder.compare(() -> bits.get(from) == false, () -> bits.get(to) == false, reverseMul); - if (MissingOrder.unknownOrder(result) == false) { - return result; + if (bits.get(from) == false) { + return bits.get(to) ? -1 * reverseMul : 0; + } else if (bits.get(to) == false) { + return reverseMul; } } return compareValues(values.get(from), values.get(to)); @@ -121,9 +119,10 @@ int compare(int from, int to) { @Override int compareCurrent(int slot) { if (missingBucket) { - int result = missingOrder.compare(() -> missingCurrentValue, () -> bits.get(slot) == false, reverseMul); - if (MissingOrder.unknownOrder(result) == false) { - return result; + if (missingCurrentValue) { + return bits.get(slot) ? -1 * reverseMul : 0; + } else if (bits.get(slot) == false) { + return reverseMul; } } return compareValues(currentValue, values.get(slot)); @@ -132,9 +131,10 @@ int compareCurrent(int slot) { @Override int compareCurrentWithAfter() { if (missingBucket) { - int result = missingOrder.compare(() -> missingCurrentValue, () -> Objects.isNull(afterValue), reverseMul); - if (MissingOrder.unknownOrder(result) == false) { - return result; + if (missingCurrentValue) { + return afterValue != null ? -1 * reverseMul : 0; + } else if (afterValue == null) { + return reverseMul; } } return compareValues(currentValue, afterValue); diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/SingleDimensionValuesSource.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/SingleDimensionValuesSource.java index 94b108e863e3d..faa94963ae5c9 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/SingleDimensionValuesSource.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/SingleDimensionValuesSource.java @@ -41,13 +41,10 @@ import org.opensearch.index.mapper.MappedFieldType; import org.opensearch.search.DocValueFormat; import org.opensearch.search.aggregations.LeafBucketCollector; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import org.opensearch.search.sort.SortOrder; import java.io.IOException; -import static org.opensearch.search.aggregations.bucket.missing.MissingOrder.LAST; - /** * A source that can record and compare values of similar type. */ @@ -57,7 +54,6 @@ abstract class SingleDimensionValuesSource> implements R @Nullable protected final MappedFieldType fieldType; protected final boolean missingBucket; - protected final MissingOrder missingOrder; protected final int size; protected final int reverseMul; @@ -71,7 +67,6 @@ abstract class SingleDimensionValuesSource> implements R * @param format The format of the source. * @param fieldType The field type or null if the source is a script. * @param missingBucket If true, an explicit `null bucket represents documents with missing values. - * @param missingOrder The `null bucket's position. * @param size The number of values to record. * @param reverseMul -1 if the natural order ({@link SortOrder#ASC} should be reversed. */ @@ -80,7 +75,6 @@ abstract class SingleDimensionValuesSource> implements R DocValueFormat format, @Nullable MappedFieldType fieldType, boolean missingBucket, - MissingOrder missingOrder, int size, int reverseMul ) { @@ -88,7 +82,6 @@ abstract class SingleDimensionValuesSource> implements R this.format = format; this.fieldType = fieldType; this.missingBucket = missingBucket; - this.missingOrder = missingOrder; this.size = size; this.reverseMul = reverseMul; this.afterValue = null; @@ -174,11 +167,8 @@ T getAfter() { * Returns true if a {@link SortedDocsProducer} should be used to optimize the execution. */ protected boolean checkIfSortedDocsIsApplicable(IndexReader reader, MappedFieldType fieldType) { - if (fieldType == null - || (missingBucket && (afterValue == null || reverseMul == 1 && missingOrder == LAST)) - || fieldType.isSearchable() == false - || - // inverse of the natural order + if (fieldType == null || (missingBucket && afterValue == null) || fieldType.isSearchable() == false || + // inverse of the natural order reverseMul == -1) { return false; } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/TermsValuesSourceBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/TermsValuesSourceBuilder.java index c871e8d0c7d5b..d70b9dece82c0 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/TermsValuesSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/TermsValuesSourceBuilder.java @@ -43,7 +43,6 @@ import org.opensearch.index.query.QueryShardContext; import org.opensearch.script.Script; import org.opensearch.search.DocValueFormat; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import org.opensearch.search.aggregations.support.CoreValuesSourceType; import org.opensearch.search.aggregations.support.ValuesSource; import org.opensearch.search.aggregations.support.ValuesSourceConfig; @@ -69,7 +68,6 @@ CompositeValuesSourceConfig apply( boolean hasScript, // probably redundant with the config, but currently we check this two different ways... String format, boolean missingBucket, - MissingOrder missingOrder, SortOrder order ); } @@ -113,7 +111,7 @@ static void register(ValuesSourceRegistry.Builder builder) { builder.register( REGISTRY_KEY, org.opensearch.common.collect.List.of(CoreValuesSourceType.DATE, CoreValuesSourceType.NUMERIC, CoreValuesSourceType.BOOLEAN), - (valuesSourceConfig, name, hasScript, format, missingBucket, missingOrder, order) -> { + (valuesSourceConfig, name, hasScript, format, missingBucket, order) -> { final DocValueFormat docValueFormat; if (format == null && valuesSourceConfig.valueSourceType() == CoreValuesSourceType.DATE) { // defaults to the raw format on date fields (preserve timestamp as longs). @@ -128,7 +126,6 @@ static void register(ValuesSourceRegistry.Builder builder) { docValueFormat, order, missingBucket, - missingOrder, hasScript, ( BigArrays bigArrays, @@ -145,7 +142,6 @@ static void register(ValuesSourceRegistry.Builder builder) { vs::doubleValues, compositeValuesSourceConfig.format(), compositeValuesSourceConfig.missingBucket(), - compositeValuesSourceConfig.missingOrder(), size, compositeValuesSourceConfig.reverseMul() ); @@ -160,7 +156,6 @@ static void register(ValuesSourceRegistry.Builder builder) { rounding, compositeValuesSourceConfig.format(), compositeValuesSourceConfig.missingBucket(), - compositeValuesSourceConfig.missingOrder(), size, compositeValuesSourceConfig.reverseMul() ); @@ -175,14 +170,13 @@ static void register(ValuesSourceRegistry.Builder builder) { builder.register( REGISTRY_KEY, org.opensearch.common.collect.List.of(CoreValuesSourceType.BYTES, CoreValuesSourceType.IP), - (valuesSourceConfig, name, hasScript, format, missingBucket, missingOrder, order) -> new CompositeValuesSourceConfig( + (valuesSourceConfig, name, hasScript, format, missingBucket, order) -> new CompositeValuesSourceConfig( name, valuesSourceConfig.fieldType(), valuesSourceConfig.getValuesSource(), valuesSourceConfig.format(), order, missingBucket, - missingOrder, hasScript, ( BigArrays bigArrays, @@ -199,7 +193,6 @@ static void register(ValuesSourceRegistry.Builder builder) { vs::globalOrdinalsValues, compositeValuesSourceConfig.format(), compositeValuesSourceConfig.missingBucket(), - compositeValuesSourceConfig.missingOrder(), size, compositeValuesSourceConfig.reverseMul() ); @@ -212,7 +205,6 @@ static void register(ValuesSourceRegistry.Builder builder) { vs::bytesValues, compositeValuesSourceConfig.format(), compositeValuesSourceConfig.missingBucket(), - compositeValuesSourceConfig.missingOrder(), size, compositeValuesSourceConfig.reverseMul() ); @@ -232,6 +224,6 @@ protected ValuesSourceType getDefaultValuesSourceType() { protected CompositeValuesSourceConfig innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config) throws IOException { return queryShardContext.getValuesSourceRegistry() .getAggregator(REGISTRY_KEY, config) - .apply(config, name, script() != null, format(), missingBucket(), missingOrder(), order()); + .apply(config, name, script() != null, format(), missingBucket(), order()); } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/missing/MissingOrder.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/missing/MissingOrder.java deleted file mode 100644 index 06086f507f665..0000000000000 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/missing/MissingOrder.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.search.aggregations.bucket.missing; - -import org.opensearch.common.inject.Provider; -import org.opensearch.common.io.stream.StreamInput; -import org.opensearch.common.io.stream.StreamOutput; -import org.opensearch.common.io.stream.Writeable; - -import java.io.IOException; -import java.util.Locale; - -/** - * Composite Aggregation Missing bucket order. - */ -public enum MissingOrder implements Writeable { - /** - * missing first. - */ - FIRST { - @Override - public int compare(Provider leftIsMissing, Provider rightIsMissing, int reverseMul) { - if (leftIsMissing.get()) { - return rightIsMissing.get() ? 0 : -1; - } else if (rightIsMissing.get()) { - return 1; - } - return MISSING_ORDER_UNKNOWN; - } - - @Override - public String toString() { - return "first"; - } - }, - - /** - * missing last. - */ - LAST { - @Override - public int compare(Provider leftIsMissing, Provider rightIsMissing, int reverseMul) { - if (leftIsMissing.get()) { - return rightIsMissing.get() ? 0 : 1; - } else if (rightIsMissing.get()) { - return -1; - } - return MISSING_ORDER_UNKNOWN; - } - - @Override - public String toString() { - return "last"; - } - }, - - /** - * Default: ASC missing first / DESC missing last - */ - DEFAULT { - @Override - public int compare(Provider leftIsMissing, Provider rightIsMissing, int reverseMul) { - if (leftIsMissing.get()) { - return rightIsMissing.get() ? 0 : -1 * reverseMul; - } else if (rightIsMissing.get()) { - return reverseMul; - } - return MISSING_ORDER_UNKNOWN; - } - - @Override - public String toString() { - return "default"; - } - }; - - public static final String NAME = "missing_order"; - - private static int MISSING_ORDER_UNKNOWN = Integer.MIN_VALUE; - - public static MissingOrder readFromStream(StreamInput in) throws IOException { - return in.readEnum(MissingOrder.class); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - out.writeEnum(this); - } - - public static boolean isDefault(MissingOrder order) { - return order == DEFAULT; - } - - public static MissingOrder fromString(String order) { - return valueOf(order.toUpperCase(Locale.ROOT)); - } - - public static boolean unknownOrder(int v) { - return v == MISSING_ORDER_UNKNOWN; - } - - public abstract int compare(Provider leftIsMissing, Provider rightIsMissing, int reverseMul); -} diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregationBuilderTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregationBuilderTests.java index c4a87f3993bb4..4316acc8c2b85 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregationBuilderTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregationBuilderTests.java @@ -37,7 +37,6 @@ import org.opensearch.search.aggregations.BaseAggregationTestCase; import org.opensearch.search.aggregations.bucket.geogrid.GeoTileUtils; import org.opensearch.search.aggregations.bucket.histogram.DateHistogramInterval; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import org.opensearch.search.sort.SortOrder; import java.util.ArrayList; @@ -70,7 +69,6 @@ private DateHistogramValuesSourceBuilder randomDateHistogramSourceBuilder() { if (randomBoolean()) { histo.missingBucket(true); } - histo.missingOrder(randomFrom(MissingOrder.values())); return histo; } @@ -96,7 +94,6 @@ private TermsValuesSourceBuilder randomTermsSourceBuilder() { if (randomBoolean()) { terms.missingBucket(true); } - terms.missingOrder(randomFrom(MissingOrder.values())); return terms; } @@ -111,7 +108,6 @@ private HistogramValuesSourceBuilder randomHistogramSourceBuilder() { histo.missingBucket(true); } histo.interval(randomDoubleBetween(Math.nextUp(0), Double.MAX_VALUE, false)); - histo.missingOrder(randomFrom(MissingOrder.values())); return histo; } diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregatorTests.java index f81bd012bfa63..e8df1753a79b8 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregatorTests.java @@ -82,7 +82,6 @@ import org.opensearch.search.aggregations.bucket.geogrid.GeoTileGridAggregationBuilder; import org.opensearch.search.aggregations.bucket.geogrid.GeoTileUtils; import org.opensearch.search.aggregations.bucket.histogram.DateHistogramInterval; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import org.opensearch.search.aggregations.bucket.terms.StringTerms; import org.opensearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.opensearch.search.aggregations.metrics.InternalMax; @@ -587,84 +586,6 @@ public void testWithKeywordAndMissingBucket() throws Exception { assertEquals(0, result.getBuckets().size()); assertNull(result.afterKey()); }); - - // sort ascending, null bucket is first, same as default. - testSearchCase(Arrays.asList(new MatchAllDocsQuery()), dataset, () -> { - TermsValuesSourceBuilder terms = new TermsValuesSourceBuilder("keyword").field("keyword") - .missingBucket(true) - .missingOrder(MissingOrder.FIRST); - return new CompositeAggregationBuilder("name", Collections.singletonList(terms)); - }, (result) -> { - assertEquals(4, result.getBuckets().size()); - assertEquals("{keyword=d}", result.afterKey().toString()); - assertEquals("{keyword=null}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(0).getDocCount()); - assertEquals("{keyword=a}", result.getBuckets().get(1).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(1).getDocCount()); - assertEquals("{keyword=c}", result.getBuckets().get(2).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(2).getDocCount()); - assertEquals("{keyword=d}", result.getBuckets().get(3).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(3).getDocCount()); - }); - - // sort ascending, null bucket is last. - testSearchCase(Arrays.asList(new MatchAllDocsQuery()), dataset, () -> { - TermsValuesSourceBuilder terms = new TermsValuesSourceBuilder("keyword").field("keyword") - .missingBucket(true) - .missingOrder(MissingOrder.LAST); - return new CompositeAggregationBuilder("name", Collections.singletonList(terms)); - }, (result) -> { - assertEquals(4, result.getBuckets().size()); - assertEquals("{keyword=null}", result.afterKey().toString()); - assertEquals("{keyword=a}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(0).getDocCount()); - assertEquals("{keyword=c}", result.getBuckets().get(1).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(1).getDocCount()); - assertEquals("{keyword=d}", result.getBuckets().get(2).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(2).getDocCount()); - assertEquals("{keyword=null}", result.getBuckets().get(3).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(3).getDocCount()); - }); - - // sort descending, null bucket is last, same as default - testSearchCase(Arrays.asList(new MatchAllDocsQuery()), dataset, () -> { - TermsValuesSourceBuilder terms = new TermsValuesSourceBuilder("keyword").field("keyword") - .missingBucket(true) - .missingOrder(MissingOrder.LAST) - .order(SortOrder.DESC); - return new CompositeAggregationBuilder("name", Collections.singletonList(terms)); - }, (result) -> { - assertEquals(4, result.getBuckets().size()); - assertEquals("{keyword=null}", result.afterKey().toString()); - assertEquals("{keyword=null}", result.getBuckets().get(3).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(3).getDocCount()); - assertEquals("{keyword=a}", result.getBuckets().get(2).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(2).getDocCount()); - assertEquals("{keyword=c}", result.getBuckets().get(1).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(1).getDocCount()); - assertEquals("{keyword=d}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(0).getDocCount()); - }); - - // sort descending, null bucket is first - testSearchCase(Arrays.asList(new MatchAllDocsQuery()), dataset, () -> { - TermsValuesSourceBuilder terms = new TermsValuesSourceBuilder("keyword").field("keyword") - .missingBucket(true) - .missingOrder(MissingOrder.FIRST) - .order(SortOrder.DESC); - return new CompositeAggregationBuilder("name", Collections.singletonList(terms)); - }, (result) -> { - assertEquals(4, result.getBuckets().size()); - assertEquals("{keyword=a}", result.afterKey().toString()); - assertEquals("{keyword=null}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(0).getDocCount()); - assertEquals("{keyword=d}", result.getBuckets().get(1).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(1).getDocCount()); - assertEquals("{keyword=c}", result.getBuckets().get(2).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(2).getDocCount()); - assertEquals("{keyword=a}", result.getBuckets().get(3).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(3).getDocCount()); - }); } public void testWithKeywordMissingAfter() throws Exception { @@ -980,14 +901,14 @@ public void testWithKeywordLongAndMissingBucket() throws Exception { final List>> dataset = new ArrayList<>(); dataset.addAll( Arrays.asList( - createDocument("double", 0d, "keyword", "a", "long", 100L), + createDocument("keyword", "a", "long", 100L), createDocument("double", 0d), - createDocument("double", 0d, "keyword", "c", "long", 100L), - createDocument("double", 0d, "keyword", "a", "long", 0L), - createDocument("double", 0d, "keyword", "d", "long", 10L), - createDocument("double", 0d, "keyword", "c"), - createDocument("double", 0d, "keyword", "c", "long", 100L), - createDocument("double", 0d, "long", 100L), + createDocument("keyword", "c", "long", 100L), + createDocument("keyword", "a", "long", 0L), + createDocument("keyword", "d", "long", 10L), + createDocument("keyword", "c"), + createDocument("keyword", "c", "long", 100L), + createDocument("long", 100L), createDocument("double", 0d) ) ); @@ -1040,112 +961,6 @@ public void testWithKeywordLongAndMissingBucket() throws Exception { assertEquals(1L, result.getBuckets().get(1).getDocCount()); } ); - - // keyword null bucket is last, long null bucket is last - testSearchCase( - Arrays.asList(new MatchAllDocsQuery(), new DocValuesFieldExistsQuery("double")), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new TermsValuesSourceBuilder("keyword").field("keyword").missingBucket(true).missingOrder(MissingOrder.LAST), - new TermsValuesSourceBuilder("long").field("long").missingBucket(true).missingOrder(MissingOrder.LAST) - ) - ), - (result) -> { - assertEquals(7, result.getBuckets().size()); - assertEquals("{keyword=null, long=null}", result.afterKey().toString()); - assertEquals("{keyword=null, long=null}", result.getBuckets().get(6).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(6).getDocCount()); - assertEquals("{keyword=null, long=100}", result.getBuckets().get(5).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(5).getDocCount()); - } - ); - - // keyword null bucket is last, long null bucket is first - testSearchCase( - Arrays.asList(new MatchAllDocsQuery(), new DocValuesFieldExistsQuery("double")), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new TermsValuesSourceBuilder("keyword").field("keyword").missingBucket(true).missingOrder(MissingOrder.LAST), - new TermsValuesSourceBuilder("long").field("long").missingBucket(true).missingOrder(MissingOrder.FIRST) - ) - ), - (result) -> { - assertEquals(7, result.getBuckets().size()); - assertEquals("{keyword=null, long=100}", result.afterKey().toString()); - assertEquals("{keyword=null, long=100}", result.getBuckets().get(6).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(6).getDocCount()); - assertEquals("{keyword=null, long=null}", result.getBuckets().get(5).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(5).getDocCount()); - } - ); - - // asc, null bucket is last, search after non null value - testSearchCase( - Arrays.asList(new MatchAllDocsQuery(), new DocValuesFieldExistsQuery("double")), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList(new TermsValuesSourceBuilder("keyword").field("keyword").missingBucket(true).missingOrder(MissingOrder.LAST)) - ).aggregateAfter(createAfterKey("keyword", "c")), - (result) -> { - assertEquals(2, result.getBuckets().size()); - assertEquals("{keyword=null}", result.afterKey().toString()); - assertEquals("{keyword=d}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(0).getDocCount()); - assertEquals("{keyword=null}", result.getBuckets().get(1).getKeyAsString()); - assertEquals(3L, result.getBuckets().get(1).getDocCount()); - } - ); - - // desc, null bucket is last, search after non null value - testSearchCase( - Arrays.asList(new MatchAllDocsQuery(), new DocValuesFieldExistsQuery("double")), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new TermsValuesSourceBuilder("keyword").field("keyword") - .missingBucket(true) - .missingOrder(MissingOrder.LAST) - .order(SortOrder.DESC) - ) - ).aggregateAfter(createAfterKey("keyword", "c")), - (result) -> { - assertEquals(2, result.getBuckets().size()); - assertEquals("{keyword=null}", result.afterKey().toString()); - assertEquals("{keyword=a}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(0).getDocCount()); - assertEquals("{keyword=null}", result.getBuckets().get(1).getKeyAsString()); - assertEquals(3L, result.getBuckets().get(1).getDocCount()); - } - ); - - // keyword null bucket is last, long null bucket is last - testSearchCase( - Arrays.asList(new MatchAllDocsQuery(), new DocValuesFieldExistsQuery("double")), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new TermsValuesSourceBuilder("keyword").field("keyword").missingBucket(true).missingOrder(MissingOrder.LAST), - new TermsValuesSourceBuilder("long").field("long").missingBucket(true).missingOrder(MissingOrder.LAST) - ) - ).aggregateAfter(createAfterKey("keyword", "c", "long", null)), - (result) -> { - assertEquals(3, result.getBuckets().size()); - assertEquals("{keyword=null, long=null}", result.afterKey().toString()); - assertEquals("{keyword=d, long=10}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(0).getDocCount()); - assertEquals("{keyword=null, long=100}", result.getBuckets().get(1).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(1).getDocCount()); - assertEquals("{keyword=null, long=null}", result.getBuckets().get(2).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(2).getDocCount()); - } - ); } public void testMultiValuedWithKeywordAndLong() throws Exception { @@ -1904,240 +1719,6 @@ public void testWithHistogramAndKeyword() throws IOException { ); } - public void testWithHistogramBucketMissing() throws IOException { - final List>> dataset = new ArrayList<>(); - dataset.addAll( - Arrays.asList( - createDocument("price", 50L, "long", 1L), - createDocument("price", 60L, "long", 2L), - createDocument("price", 70L, "long", 3L), - createDocument("price", 62L, "long", 4L), - createDocument("long", 5L) - ) - ); - - // asc, null bucket is first - testSearchCase( - Arrays.asList(new MatchAllDocsQuery()), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new HistogramValuesSourceBuilder("price").field("price") - .missingBucket(true) - .missingOrder(MissingOrder.FIRST) - .interval(10) - ) - ), - (result) -> { - assertEquals(4, result.getBuckets().size()); - assertEquals("{price=70.0}", result.afterKey().toString()); - assertEquals("{price=null}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(0).getDocCount()); - assertEquals("{price=50.0}", result.getBuckets().get(1).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(1).getDocCount()); - assertEquals("{price=60.0}", result.getBuckets().get(2).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(2).getDocCount()); - assertEquals("{price=70.0}", result.getBuckets().get(3).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(3).getDocCount()); - } - ); - - // asc, null bucket is first, after 50.0 - testSearchCase( - Arrays.asList(new MatchAllDocsQuery()), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new HistogramValuesSourceBuilder("price").field("price") - .missingBucket(true) - .missingOrder(MissingOrder.FIRST) - .interval(10) - ) - ).aggregateAfter(createAfterKey("price", 60.0d)), - (result) -> { - assertEquals(1, result.getBuckets().size()); - assertEquals("{price=70.0}", result.afterKey().toString()); - assertEquals("{price=70.0}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(0).getDocCount()); - } - ); - - // asc, null bucket is first, after null - testSearchCase( - Arrays.asList(new MatchAllDocsQuery()), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new HistogramValuesSourceBuilder("price").field("price") - .missingBucket(true) - .missingOrder(MissingOrder.FIRST) - .interval(10) - ) - ).aggregateAfter(createAfterKey("price", null)), - (result) -> { - assertEquals(3, result.getBuckets().size()); - assertEquals("{price=70.0}", result.afterKey().toString()); - assertEquals("{price=50.0}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(0).getDocCount()); - assertEquals("{price=60.0}", result.getBuckets().get(1).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(1).getDocCount()); - assertEquals("{price=70.0}", result.getBuckets().get(2).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(2).getDocCount()); - } - ); - - // asc, null bucket is last - testSearchCase( - Arrays.asList(new MatchAllDocsQuery()), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new HistogramValuesSourceBuilder("price").field("price") - .missingBucket(true) - .missingOrder(MissingOrder.LAST) - .interval(10) - ) - ), - (result) -> { - assertEquals(4, result.getBuckets().size()); - assertEquals("{price=null}", result.afterKey().toString()); - assertEquals("{price=50.0}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(0).getDocCount()); - assertEquals("{price=60.0}", result.getBuckets().get(1).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(1).getDocCount()); - assertEquals("{price=70.0}", result.getBuckets().get(2).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(2).getDocCount()); - assertEquals("{price=null}", result.getBuckets().get(3).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(3).getDocCount()); - } - ); - - // asc, null bucket is last, after 70.0 - testSearchCase( - Arrays.asList(new MatchAllDocsQuery()), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new HistogramValuesSourceBuilder("price").field("price") - .missingBucket(true) - .missingOrder(MissingOrder.LAST) - .interval(10) - ) - ).aggregateAfter(createAfterKey("price", 70.0)), - (result) -> { - assertEquals(1, result.getBuckets().size()); - assertEquals("{price=null}", result.afterKey().toString()); - assertEquals("{price=null}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(0).getDocCount()); - } - ); - - // desc, null bucket is first - testSearchCase( - Arrays.asList(new MatchAllDocsQuery()), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new HistogramValuesSourceBuilder("price").field("price") - .missingBucket(true) - .missingOrder(MissingOrder.FIRST) - .order(SortOrder.DESC) - .interval(10) - ) - ), - (result) -> { - assertEquals(4, result.getBuckets().size()); - assertEquals("{price=50.0}", result.afterKey().toString()); - assertEquals("{price=null}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(0).getDocCount()); - assertEquals("{price=70.0}", result.getBuckets().get(1).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(1).getDocCount()); - assertEquals("{price=60.0}", result.getBuckets().get(2).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(2).getDocCount()); - assertEquals("{price=50.0}", result.getBuckets().get(3).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(3).getDocCount()); - } - ); - - // desc, null bucket is first, after 60.0 - testSearchCase( - Arrays.asList(new MatchAllDocsQuery()), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new HistogramValuesSourceBuilder("price").field("price") - .missingBucket(true) - .missingOrder(MissingOrder.FIRST) - .order(SortOrder.DESC) - .interval(10) - ) - ).aggregateAfter(createAfterKey("price", 60.0)), - (result) -> { - assertEquals(1, result.getBuckets().size()); - assertEquals("{price=50.0}", result.afterKey().toString()); - assertEquals("{price=50.0}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(0).getDocCount()); - } - ); - - // desc, null bucket is last - testSearchCase( - Arrays.asList(new MatchAllDocsQuery()), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new HistogramValuesSourceBuilder("price").field("price") - .missingBucket(true) - .missingOrder(MissingOrder.LAST) - .order(SortOrder.DESC) - .interval(10) - ) - ), - (result) -> { - assertEquals(4, result.getBuckets().size()); - assertEquals("{price=null}", result.afterKey().toString()); - assertEquals("{price=70.0}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(0).getDocCount()); - assertEquals("{price=60.0}", result.getBuckets().get(1).getKeyAsString()); - assertEquals(2L, result.getBuckets().get(1).getDocCount()); - assertEquals("{price=50.0}", result.getBuckets().get(2).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(2).getDocCount()); - assertEquals("{price=null}", result.getBuckets().get(3).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(3).getDocCount()); - } - ); - - // desc, null bucket is last, after 50.0 - testSearchCase( - Arrays.asList(new MatchAllDocsQuery()), - dataset, - () -> new CompositeAggregationBuilder( - "name", - Arrays.asList( - new HistogramValuesSourceBuilder("price").field("price") - .missingBucket(true) - .missingOrder(MissingOrder.LAST) - .order(SortOrder.DESC) - .interval(10) - ) - ).aggregateAfter(createAfterKey("price", 50.0)), - (result) -> { - assertEquals(1, result.getBuckets().size()); - assertEquals("{price=null}", result.afterKey().toString()); - assertEquals("{price=null}", result.getBuckets().get(0).getKeyAsString()); - assertEquals(1L, result.getBuckets().get(0).getDocCount()); - } - ); - } - public void testWithKeywordAndDateHistogram() throws IOException { final List>> dataset = new ArrayList<>(); dataset.addAll( diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesCollectorQueueTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesCollectorQueueTests.java index 0ad6d30df337f..a256a37814d62 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesCollectorQueueTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesCollectorQueueTests.java @@ -63,7 +63,6 @@ import org.opensearch.search.DocValueFormat; import org.opensearch.search.aggregations.AggregatorTestCase; import org.opensearch.search.aggregations.LeafBucketCollector; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import java.io.IOException; import java.util.ArrayList; @@ -278,7 +277,6 @@ private void testRandomCase(boolean forceMerge, boolean missingBucket, int index value -> value, DocValueFormat.RAW, missingBucket, - MissingOrder.DEFAULT, size, 1 ); @@ -289,7 +287,6 @@ private void testRandomCase(boolean forceMerge, boolean missingBucket, int index context -> FieldData.sortableLongBitsToDoubles(DocValues.getSortedNumeric(context.reader(), fieldType.name())), DocValueFormat.RAW, missingBucket, - MissingOrder.DEFAULT, size, 1 ); @@ -303,7 +300,6 @@ private void testRandomCase(boolean forceMerge, boolean missingBucket, int index context -> DocValues.getSortedSet(context.reader(), fieldType.name()), DocValueFormat.RAW, missingBucket, - MissingOrder.DEFAULT, size, 1 ); @@ -315,7 +311,6 @@ private void testRandomCase(boolean forceMerge, boolean missingBucket, int index context -> FieldData.toString(DocValues.getSortedSet(context.reader(), fieldType.name())), DocValueFormat.RAW, missingBucket, - MissingOrder.DEFAULT, size, 1 ); diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/InternalCompositeTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/InternalCompositeTests.java index 4121954c1ede2..311c688f23ff6 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/InternalCompositeTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/InternalCompositeTests.java @@ -39,7 +39,6 @@ import org.opensearch.search.aggregations.InternalAggregation; import org.opensearch.search.aggregations.InternalAggregations; import org.opensearch.search.aggregations.ParsedAggregation; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import org.opensearch.test.InternalMultiBucketAggregationTestCase; import org.junit.After; @@ -72,7 +71,6 @@ public class InternalCompositeTests extends InternalMultiBucketAggregationTestCa private List sourceNames; private List formats; private int[] reverseMuls; - private MissingOrder[] missingOrders; private int[] types; private int size; @@ -102,12 +100,10 @@ public void setUp() throws Exception { sourceNames = new ArrayList<>(); formats = new ArrayList<>(); reverseMuls = new int[numFields]; - missingOrders = new MissingOrder[numFields]; types = new int[numFields]; for (int i = 0; i < numFields; i++) { sourceNames.add("field_" + i); reverseMuls[i] = randomBoolean() ? 1 : -1; - missingOrders[i] = randomFrom(MissingOrder.values()); int type = randomIntBetween(0, 2); types[i] = type; formats.add(randomDocValueFormat(type == 0)); @@ -186,7 +182,6 @@ protected InternalComposite createTestInstance(String name, Map formats, key, reverseMuls, - missingOrders, 1L, aggregations ); @@ -194,18 +189,7 @@ protected InternalComposite createTestInstance(String name, Map } Collections.sort(buckets, (o1, o2) -> o1.compareKey(o2)); CompositeKey lastBucket = buckets.size() > 0 ? buckets.get(buckets.size() - 1).getRawKey() : null; - return new InternalComposite( - name, - size, - sourceNames, - formats, - buckets, - lastBucket, - reverseMuls, - missingOrders, - randomBoolean(), - metadata - ); + return new InternalComposite(name, size, sourceNames, formats, buckets, lastBucket, reverseMuls, randomBoolean(), metadata); } @Override @@ -230,7 +214,6 @@ protected InternalComposite mutateInstance(InternalComposite instance) throws IO formats, createCompositeKey(), reverseMuls, - missingOrders, randomLongBetween(1, 100), InternalAggregations.EMPTY ) @@ -256,7 +239,6 @@ protected InternalComposite mutateInstance(InternalComposite instance) throws IO buckets, lastBucket, reverseMuls, - missingOrders, randomBoolean(), metadata ); @@ -313,7 +295,6 @@ public void testReduceUnmapped() throws IOException { emptyList(), null, reverseMuls, - missingOrders, true, emptyMap() ); diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/SingleDimensionValuesSourceTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/SingleDimensionValuesSourceTests.java index 6569a269169eb..19cf1ef7044c9 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/SingleDimensionValuesSourceTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/SingleDimensionValuesSourceTests.java @@ -47,7 +47,6 @@ import org.opensearch.index.mapper.MappedFieldType; import org.opensearch.index.mapper.NumberFieldMapper; import org.opensearch.search.DocValueFormat; -import org.opensearch.search.aggregations.bucket.missing.MissingOrder; import org.opensearch.test.OpenSearchTestCase; import static org.mockito.Mockito.mock; @@ -63,7 +62,6 @@ public void testBinarySorted() { context -> null, DocValueFormat.RAW, false, - MissingOrder.DEFAULT, 1, 1 ); @@ -81,7 +79,6 @@ public void testBinarySorted() { context -> null, DocValueFormat.RAW, true, - MissingOrder.DEFAULT, 1, 1 ); @@ -95,24 +92,13 @@ public void testBinarySorted() { context -> null, DocValueFormat.RAW, false, - MissingOrder.DEFAULT, 0, -1 ); assertNull(source.createSortedDocsProducerOrNull(reader, null)); MappedFieldType ip = new IpFieldMapper.IpFieldType("ip"); - source = new BinaryValuesSource( - BigArrays.NON_RECYCLING_INSTANCE, - (b) -> {}, - ip, - context -> null, - DocValueFormat.RAW, - false, - MissingOrder.DEFAULT, - 1, - 1 - ); + source = new BinaryValuesSource(BigArrays.NON_RECYCLING_INSTANCE, (b) -> {}, ip, context -> null, DocValueFormat.RAW, false, 1, 1); assertNull(source.createSortedDocsProducerOrNull(reader, null)); } @@ -124,7 +110,6 @@ public void testGlobalOrdinalsSorted() { context -> null, DocValueFormat.RAW, false, - MissingOrder.DEFAULT, 1, 1 ); @@ -135,16 +120,7 @@ public void testGlobalOrdinalsSorted() { assertNull(source.createSortedDocsProducerOrNull(reader, new TermQuery(new Term("foo", "bar")))); assertNull(source.createSortedDocsProducerOrNull(reader, new TermQuery(new Term("keyword", "toto)")))); - source = new GlobalOrdinalValuesSource( - BigArrays.NON_RECYCLING_INSTANCE, - keyword, - context -> null, - DocValueFormat.RAW, - true, - MissingOrder.DEFAULT, - 1, - 1 - ); + source = new GlobalOrdinalValuesSource(BigArrays.NON_RECYCLING_INSTANCE, keyword, context -> null, DocValueFormat.RAW, true, 1, 1); assertNull(source.createSortedDocsProducerOrNull(reader, new MatchAllDocsQuery())); assertNull(source.createSortedDocsProducerOrNull(reader, null)); assertNull(source.createSortedDocsProducerOrNull(reader, new TermQuery(new Term("foo", "bar")))); @@ -155,7 +131,6 @@ public void testGlobalOrdinalsSorted() { context -> null, DocValueFormat.RAW, false, - MissingOrder.DEFAULT, 1, -1 ); @@ -163,16 +138,7 @@ public void testGlobalOrdinalsSorted() { assertNull(source.createSortedDocsProducerOrNull(reader, new TermQuery(new Term("foo", "bar")))); final MappedFieldType ip = new IpFieldMapper.IpFieldType("ip"); - source = new GlobalOrdinalValuesSource( - BigArrays.NON_RECYCLING_INSTANCE, - ip, - context -> null, - DocValueFormat.RAW, - false, - MissingOrder.DEFAULT, - 1, - 1 - ); + source = new GlobalOrdinalValuesSource(BigArrays.NON_RECYCLING_INSTANCE, ip, context -> null, DocValueFormat.RAW, false, 1, 1); assertNull(source.createSortedDocsProducerOrNull(reader, null)); assertNull(source.createSortedDocsProducerOrNull(reader, new TermQuery(new Term("foo", "bar")))); } @@ -193,7 +159,6 @@ public void testNumericSorted() { value -> value, DocValueFormat.RAW, false, - MissingOrder.DEFAULT, 1, 1 ); @@ -227,7 +192,6 @@ public void testNumericSorted() { value -> value, DocValueFormat.RAW, true, - MissingOrder.DEFAULT, 1, 1 ); @@ -249,7 +213,6 @@ public void testNumericSorted() { value -> value, DocValueFormat.RAW, false, - MissingOrder.DEFAULT, 1, -1 ); @@ -268,7 +231,6 @@ public void testNumericSorted() { context -> null, DocValueFormat.RAW, false, - MissingOrder.DEFAULT, 1, 1 );