add tests to StatsAggregatorTests (#53768)
Adds tests for supported ValuesSourceTypes, unmapped fields, scripting, and the missing param. The tests for unmapped fields and scripting are migrated from the StatsIT integration test
This commit is contained in:
parent
c87b830d06
commit
eb14635f1f
|
@ -22,30 +22,62 @@ import org.apache.lucene.document.Document;
|
||||||
import org.apache.lucene.document.NumericDocValuesField;
|
import org.apache.lucene.document.NumericDocValuesField;
|
||||||
import org.apache.lucene.document.SortedNumericDocValuesField;
|
import org.apache.lucene.document.SortedNumericDocValuesField;
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
|
import org.apache.lucene.index.IndexableField;
|
||||||
|
import org.apache.lucene.index.MultiReader;
|
||||||
import org.apache.lucene.index.RandomIndexWriter;
|
import org.apache.lucene.index.RandomIndexWriter;
|
||||||
import org.apache.lucene.search.IndexSearcher;
|
import org.apache.lucene.search.IndexSearcher;
|
||||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.util.NumericUtils;
|
import org.apache.lucene.util.NumericUtils;
|
||||||
import org.elasticsearch.common.CheckedConsumer;
|
import org.elasticsearch.common.CheckedConsumer;
|
||||||
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||||
import org.elasticsearch.index.mapper.NumberFieldMapper;
|
import org.elasticsearch.index.mapper.NumberFieldMapper;
|
||||||
|
import org.elasticsearch.index.mapper.NumberFieldMapper.NumberType;
|
||||||
|
import org.elasticsearch.script.MockScriptEngine;
|
||||||
|
import org.elasticsearch.script.Script;
|
||||||
|
import org.elasticsearch.script.ScriptEngine;
|
||||||
|
import org.elasticsearch.script.ScriptModule;
|
||||||
|
import org.elasticsearch.script.ScriptService;
|
||||||
|
import org.elasticsearch.script.ScriptType;
|
||||||
|
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||||
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.ValuesSourceType;
|
||||||
|
import org.elasticsearch.search.lookup.LeafDocLookup;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import static java.util.Collections.emptyMap;
|
||||||
|
import static java.util.Collections.emptySet;
|
||||||
import static java.util.Collections.singleton;
|
import static java.util.Collections.singleton;
|
||||||
|
import static java.util.Collections.singletonList;
|
||||||
|
import static java.util.Collections.singletonMap;
|
||||||
|
import static java.util.stream.Collectors.toList;
|
||||||
|
import static java.util.stream.Collectors.toSet;
|
||||||
|
import static org.elasticsearch.search.aggregations.AggregationBuilders.stats;
|
||||||
|
|
||||||
public class StatsAggregatorTests extends AggregatorTestCase {
|
public class StatsAggregatorTests extends AggregatorTestCase {
|
||||||
static final double TOLERANCE = 1e-10;
|
|
||||||
|
private static final double TOLERANCE = 1e-10;
|
||||||
|
private static final String VALUE_SCRIPT_NAME = "value_script";
|
||||||
|
private static final String FIELD_SCRIPT_NAME = "field_script";
|
||||||
|
|
||||||
public void testEmpty() throws IOException {
|
public void testEmpty() throws IOException {
|
||||||
MappedFieldType ft =
|
final MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberType.LONG);
|
||||||
new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.LONG);
|
|
||||||
ft.setName("field");
|
ft.setName("field");
|
||||||
testCase(ft, iw -> {},
|
testCase(
|
||||||
|
stats("_name").field(ft.name()),
|
||||||
|
iw -> {},
|
||||||
stats -> {
|
stats -> {
|
||||||
assertEquals(0d, stats.getCount(), 0);
|
assertEquals(0d, stats.getCount(), 0);
|
||||||
assertEquals(0d, stats.getSum(), 0);
|
assertEquals(0d, stats.getSum(), 0);
|
||||||
|
@ -53,16 +85,17 @@ public class StatsAggregatorTests extends AggregatorTestCase {
|
||||||
assertEquals(Double.POSITIVE_INFINITY, stats.getMin(), 0);
|
assertEquals(Double.POSITIVE_INFINITY, stats.getMin(), 0);
|
||||||
assertEquals(Double.NEGATIVE_INFINITY, stats.getMax(), 0);
|
assertEquals(Double.NEGATIVE_INFINITY, stats.getMax(), 0);
|
||||||
assertFalse(AggregationInspectionHelper.hasValue(stats));
|
assertFalse(AggregationInspectionHelper.hasValue(stats));
|
||||||
}
|
},
|
||||||
|
singleton(ft)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRandomDoubles() throws IOException {
|
public void testRandomDoubles() throws IOException {
|
||||||
MappedFieldType ft =
|
final MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberType.DOUBLE);
|
||||||
new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.DOUBLE);
|
|
||||||
ft.setName("field");
|
ft.setName("field");
|
||||||
final SimpleStatsAggregator expected = new SimpleStatsAggregator();
|
final SimpleStatsAggregator expected = new SimpleStatsAggregator();
|
||||||
testCase(ft,
|
testCase(
|
||||||
|
stats("_name").field(ft.name()),
|
||||||
iw -> {
|
iw -> {
|
||||||
int numDocs = randomIntBetween(10, 50);
|
int numDocs = randomIntBetween(10, 50);
|
||||||
for (int i = 0; i < numDocs; i++) {
|
for (int i = 0; i < numDocs; i++) {
|
||||||
|
@ -71,7 +104,7 @@ public class StatsAggregatorTests extends AggregatorTestCase {
|
||||||
for (int j = 0; j < numValues; j++) {
|
for (int j = 0; j < numValues; j++) {
|
||||||
double value = randomDoubleBetween(-100d, 100d, true);
|
double value = randomDoubleBetween(-100d, 100d, true);
|
||||||
long valueAsLong = NumericUtils.doubleToSortableLong(value);
|
long valueAsLong = NumericUtils.doubleToSortableLong(value);
|
||||||
doc.add(new SortedNumericDocValuesField("field", valueAsLong));
|
doc.add(new SortedNumericDocValuesField(ft.name(), valueAsLong));
|
||||||
expected.add(value);
|
expected.add(value);
|
||||||
}
|
}
|
||||||
iw.addDocument(doc);
|
iw.addDocument(doc);
|
||||||
|
@ -84,30 +117,16 @@ public class StatsAggregatorTests extends AggregatorTestCase {
|
||||||
assertEquals(expected.max, stats.getMax(), 0);
|
assertEquals(expected.max, stats.getMax(), 0);
|
||||||
assertEquals(expected.sum / expected.count, stats.getAvg(), TOLERANCE);
|
assertEquals(expected.sum / expected.count, stats.getAvg(), TOLERANCE);
|
||||||
assertTrue(AggregationInspectionHelper.hasValue(stats));
|
assertTrue(AggregationInspectionHelper.hasValue(stats));
|
||||||
}
|
},
|
||||||
|
singleton(ft)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRandomLongs() throws IOException {
|
public void testRandomLongs() throws IOException {
|
||||||
MappedFieldType ft =
|
randomLongsTestCase(
|
||||||
new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.LONG);
|
randomIntBetween(1, 5),
|
||||||
ft.setName("field");
|
stats("_name").field("field"),
|
||||||
final SimpleStatsAggregator expected = new SimpleStatsAggregator();
|
(expected, stats) -> {
|
||||||
testCase(ft,
|
|
||||||
iw -> {
|
|
||||||
int numDocs = randomIntBetween(10, 50);
|
|
||||||
for (int i = 0; i < numDocs; i++) {
|
|
||||||
Document doc = new Document();
|
|
||||||
int numValues = randomIntBetween(1, 5);
|
|
||||||
for (int j = 0; j < numValues; j++) {
|
|
||||||
long value = randomIntBetween(-100, 100);
|
|
||||||
doc.add(new SortedNumericDocValuesField("field", value));
|
|
||||||
expected.add(value);
|
|
||||||
}
|
|
||||||
iw.addDocument(doc);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
stats -> {
|
|
||||||
assertEquals(expected.count, stats.getCount(), 0);
|
assertEquals(expected.count, stats.getCount(), 0);
|
||||||
assertEquals(expected.sum, stats.getSum(), TOLERANCE);
|
assertEquals(expected.sum, stats.getSum(), TOLERANCE);
|
||||||
assertEquals(expected.min, stats.getMin(), 0);
|
assertEquals(expected.min, stats.getMin(), 0);
|
||||||
|
@ -151,7 +170,7 @@ public class StatsAggregatorTests extends AggregatorTestCase {
|
||||||
|
|
||||||
private void verifySummationOfDoubles(double[] values, double expectedSum,
|
private void verifySummationOfDoubles(double[] values, double expectedSum,
|
||||||
double expectedAvg, double delta) throws IOException {
|
double expectedAvg, double delta) throws IOException {
|
||||||
MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.DOUBLE);
|
MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberType.DOUBLE);
|
||||||
ft.setName("field");
|
ft.setName("field");
|
||||||
|
|
||||||
double max = Double.NEGATIVE_INFINITY;
|
double max = Double.NEGATIVE_INFINITY;
|
||||||
|
@ -162,10 +181,11 @@ public class StatsAggregatorTests extends AggregatorTestCase {
|
||||||
}
|
}
|
||||||
double expectedMax = max;
|
double expectedMax = max;
|
||||||
double expectedMin = min;
|
double expectedMin = min;
|
||||||
testCase(ft,
|
testCase(
|
||||||
|
stats("_name").field(ft.name()),
|
||||||
iw -> {
|
iw -> {
|
||||||
for (double value : values) {
|
for (double value : values) {
|
||||||
iw.addDocument(singleton(new NumericDocValuesField("field", NumericUtils.doubleToSortableLong(value))));
|
iw.addDocument(singleton(new NumericDocValuesField(ft.name(), NumericUtils.doubleToSortableLong(value))));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
stats -> {
|
stats -> {
|
||||||
|
@ -174,20 +194,251 @@ public class StatsAggregatorTests extends AggregatorTestCase {
|
||||||
assertEquals(expectedSum, stats.getSum(), delta);
|
assertEquals(expectedSum, stats.getSum(), delta);
|
||||||
assertEquals(expectedMax, stats.getMax(), 0d);
|
assertEquals(expectedMax, stats.getMax(), 0d);
|
||||||
assertEquals(expectedMin, stats.getMin(), 0d);
|
assertEquals(expectedMin, stats.getMin(), 0d);
|
||||||
|
assertTrue(AggregationInspectionHelper.hasValue(stats));
|
||||||
|
},
|
||||||
|
singleton(ft)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testUnmapped() throws IOException {
|
||||||
|
randomLongsTestCase(
|
||||||
|
randomIntBetween(1, 5),
|
||||||
|
stats("_name").field("unmapped_field"),
|
||||||
|
(expected, stats) -> {
|
||||||
|
assertEquals(0d, stats.getCount(), 0);
|
||||||
|
assertEquals(0d, stats.getSum(), 0);
|
||||||
|
assertEquals(Float.NaN, stats.getAvg(), 0);
|
||||||
|
assertEquals(Double.POSITIVE_INFINITY, stats.getMin(), 0);
|
||||||
|
assertEquals(Double.NEGATIVE_INFINITY, stats.getMax(), 0);
|
||||||
|
assertFalse(AggregationInspectionHelper.hasValue(stats));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCase(MappedFieldType ft,
|
public void testPartiallyUnmapped() throws IOException {
|
||||||
CheckedConsumer<RandomIndexWriter, IOException> buildIndex,
|
try (Directory mappedDirectory = newDirectory();
|
||||||
Consumer<InternalStats> verify) throws IOException {
|
Directory unmappedDirectory = newDirectory();
|
||||||
|
RandomIndexWriter mappedWriter = new RandomIndexWriter(random(), mappedDirectory);
|
||||||
|
RandomIndexWriter unmappedWriter = new RandomIndexWriter(random(), unmappedDirectory)) {
|
||||||
|
|
||||||
|
final MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberType.LONG);
|
||||||
|
ft.setName("field");
|
||||||
|
final SimpleStatsAggregator expected = new SimpleStatsAggregator();
|
||||||
|
final int numDocs = randomIntBetween(10, 50);
|
||||||
|
for (int i = 0; i < numDocs; i++) {
|
||||||
|
final long value = randomLongBetween(-100, 100);
|
||||||
|
mappedWriter.addDocument(singleton(new SortedNumericDocValuesField(ft.name(), value)));
|
||||||
|
expected.add(value);
|
||||||
|
}
|
||||||
|
final StatsAggregationBuilder builder = stats("_name").field(ft.name());
|
||||||
|
|
||||||
|
try (IndexReader mappedReader = mappedWriter.getReader();
|
||||||
|
IndexReader unmappedReader = unmappedWriter.getReader();
|
||||||
|
MultiReader multiReader = new MultiReader(mappedReader, unmappedReader)) {
|
||||||
|
|
||||||
|
final IndexSearcher searcher = new IndexSearcher(multiReader);
|
||||||
|
final InternalStats stats = search(searcher, new MatchAllDocsQuery(), builder, ft);
|
||||||
|
|
||||||
|
assertEquals(expected.count, stats.getCount(), 0);
|
||||||
|
assertEquals(expected.sum, stats.getSum(), TOLERANCE);
|
||||||
|
assertEquals(expected.max, stats.getMax(), 0);
|
||||||
|
assertEquals(expected.min, stats.getMin(), 0);
|
||||||
|
assertEquals(expected.sum / expected.count, stats.getAvg(), TOLERANCE);
|
||||||
|
assertTrue(AggregationInspectionHelper.hasValue(stats));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testValueScriptSingleValuedField() throws IOException {
|
||||||
|
randomLongsTestCase(
|
||||||
|
1,
|
||||||
|
stats("_name")
|
||||||
|
.field("field")
|
||||||
|
.script(new Script(ScriptType.INLINE, MockScriptEngine.NAME, VALUE_SCRIPT_NAME, emptyMap())),
|
||||||
|
(expected, stats) -> {
|
||||||
|
final SimpleStatsAggregator adjusted = new SimpleStatsAggregator(
|
||||||
|
expected.count,
|
||||||
|
expected.min + 1,
|
||||||
|
expected.max + 1,
|
||||||
|
expected.sum + expected.count
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(adjusted.count, stats.getCount(), 0);
|
||||||
|
assertEquals(adjusted.sum, stats.getSum(), TOLERANCE);
|
||||||
|
assertEquals(adjusted.max, stats.getMax(), 0);
|
||||||
|
assertEquals(adjusted.min, stats.getMin(), 0);
|
||||||
|
assertEquals(adjusted.sum / adjusted.count, stats.getAvg(), TOLERANCE);
|
||||||
|
assertTrue(AggregationInspectionHelper.hasValue(stats));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testValueScriptMultiValuedField() throws IOException {
|
||||||
|
final int valuesPerField = randomIntBetween(2, 5);
|
||||||
|
randomLongsTestCase(
|
||||||
|
valuesPerField,
|
||||||
|
stats("_name")
|
||||||
|
.field("field")
|
||||||
|
.script(new Script(ScriptType.INLINE, MockScriptEngine.NAME, VALUE_SCRIPT_NAME, emptyMap())),
|
||||||
|
(expected, stats) -> {
|
||||||
|
final SimpleStatsAggregator adjusted = new SimpleStatsAggregator(
|
||||||
|
expected.count,
|
||||||
|
expected.min + 1,
|
||||||
|
expected.max + 1,
|
||||||
|
expected.sum + expected.count
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(adjusted.count, stats.getCount(), 0);
|
||||||
|
assertEquals(adjusted.sum, stats.getSum(), TOLERANCE);
|
||||||
|
assertEquals(adjusted.max, stats.getMax(), 0);
|
||||||
|
assertEquals(adjusted.min, stats.getMin(), 0);
|
||||||
|
assertEquals(adjusted.sum / adjusted.count, stats.getAvg(), TOLERANCE);
|
||||||
|
assertTrue(AggregationInspectionHelper.hasValue(stats));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFieldScriptSingleValuedField() throws IOException {
|
||||||
|
randomLongsTestCase(
|
||||||
|
1,
|
||||||
|
stats("_name")
|
||||||
|
.script(new Script(ScriptType.INLINE, MockScriptEngine.NAME, FIELD_SCRIPT_NAME, singletonMap("field", "field"))),
|
||||||
|
(expected, stats) -> {
|
||||||
|
final SimpleStatsAggregator adjusted = new SimpleStatsAggregator(
|
||||||
|
expected.count,
|
||||||
|
expected.min + 1,
|
||||||
|
expected.max + 1,
|
||||||
|
expected.sum + expected.count
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(adjusted.count, stats.getCount(), 0);
|
||||||
|
assertEquals(adjusted.sum, stats.getSum(), TOLERANCE);
|
||||||
|
assertEquals(adjusted.max, stats.getMax(), 0);
|
||||||
|
assertEquals(adjusted.min, stats.getMin(), 0);
|
||||||
|
assertEquals(adjusted.sum / adjusted.count, stats.getAvg(), TOLERANCE);
|
||||||
|
assertTrue(AggregationInspectionHelper.hasValue(stats));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFieldScriptMultiValuedField() throws IOException {
|
||||||
|
final int valuesPerField = randomIntBetween(2, 5);
|
||||||
|
randomLongsTestCase(
|
||||||
|
valuesPerField,
|
||||||
|
stats("_name")
|
||||||
|
.script(new Script(ScriptType.INLINE, MockScriptEngine.NAME, FIELD_SCRIPT_NAME, singletonMap("field", "field"))),
|
||||||
|
(expected, stats) -> {
|
||||||
|
final SimpleStatsAggregator adjusted = new SimpleStatsAggregator(
|
||||||
|
expected.count,
|
||||||
|
expected.min + 1,
|
||||||
|
expected.max + 1,
|
||||||
|
expected.sum + expected.count
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(adjusted.count, stats.getCount(), 0);
|
||||||
|
assertEquals(adjusted.sum, stats.getSum(), TOLERANCE);
|
||||||
|
assertEquals(adjusted.max, stats.getMax(), 0);
|
||||||
|
assertEquals(adjusted.min, stats.getMin(), 0);
|
||||||
|
assertEquals(adjusted.sum / adjusted.count, stats.getAvg(), TOLERANCE);
|
||||||
|
assertTrue(AggregationInspectionHelper.hasValue(stats));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMissing() throws IOException {
|
||||||
|
final MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberType.LONG);
|
||||||
|
ft.setName("field");
|
||||||
|
|
||||||
|
final long missingValue = randomIntBetween(-100, 100);
|
||||||
|
|
||||||
|
final int numDocs = randomIntBetween(100, 200);
|
||||||
|
final List<Set<IndexableField>> docs = new ArrayList<>(numDocs);
|
||||||
|
final SimpleStatsAggregator expected = new SimpleStatsAggregator();
|
||||||
|
for (int i = 0; i < numDocs; i++) {
|
||||||
|
if (randomBoolean()) {
|
||||||
|
final long value = randomLongBetween(-100, 100);
|
||||||
|
docs.add(singleton(new SortedNumericDocValuesField(ft.name(), value)));
|
||||||
|
expected.add(value);
|
||||||
|
} else {
|
||||||
|
docs.add(emptySet());
|
||||||
|
expected.add(missingValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
testCase(
|
||||||
|
stats("_name")
|
||||||
|
.field(ft.name())
|
||||||
|
.missing(missingValue),
|
||||||
|
iw -> iw.addDocuments(docs),
|
||||||
|
stats -> {
|
||||||
|
assertEquals(expected.count, stats.getCount(), 0);
|
||||||
|
assertEquals(expected.sum, stats.getSum(), TOLERANCE);
|
||||||
|
assertEquals(expected.max, stats.getMax(), 0);
|
||||||
|
assertEquals(expected.min, stats.getMin(), 0);
|
||||||
|
assertEquals(expected.sum / expected.count, stats.getAvg(), TOLERANCE);
|
||||||
|
assertTrue(AggregationInspectionHelper.hasValue(stats));
|
||||||
|
},
|
||||||
|
singleton(ft)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMissingUnmapped() throws IOException {
|
||||||
|
final int valuesPerField = randomIntBetween(1, 5);
|
||||||
|
final long missingValue = randomLongBetween(-100, 100);
|
||||||
|
randomLongsTestCase(
|
||||||
|
valuesPerField,
|
||||||
|
stats("_name")
|
||||||
|
.field("unknown_field")
|
||||||
|
.missing(missingValue),
|
||||||
|
(expected, stats) -> {
|
||||||
|
final long numDocs = expected.count / valuesPerField;
|
||||||
|
assertEquals(numDocs, stats.getCount());
|
||||||
|
assertEquals(numDocs * missingValue, stats.getSum(), TOLERANCE);
|
||||||
|
assertEquals(missingValue, stats.getMax(), 0);
|
||||||
|
assertEquals(missingValue, stats.getMin(), 0);
|
||||||
|
assertEquals(missingValue, stats.getAvg(), TOLERANCE);
|
||||||
|
assertTrue(AggregationInspectionHelper.hasValue(stats));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void randomLongsTestCase(int valuesPerField,
|
||||||
|
StatsAggregationBuilder builder,
|
||||||
|
BiConsumer<SimpleStatsAggregator, InternalStats> verify) throws IOException {
|
||||||
|
|
||||||
|
final MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberType.LONG);
|
||||||
|
ft.setName("field");
|
||||||
|
|
||||||
|
final int numDocs = randomIntBetween(10, 50);
|
||||||
|
final List<Set<IndexableField>> docs = new ArrayList<>(numDocs);
|
||||||
|
final SimpleStatsAggregator expected = new SimpleStatsAggregator();
|
||||||
|
for (int iDoc = 0; iDoc < numDocs; iDoc++) {
|
||||||
|
List<Long> values = randomList(valuesPerField, valuesPerField, () -> randomLongBetween(-100, 100));
|
||||||
|
docs.add(values.stream()
|
||||||
|
.map(value -> new SortedNumericDocValuesField(ft.name(), value))
|
||||||
|
.collect(toSet()));
|
||||||
|
values.forEach(expected::add);
|
||||||
|
}
|
||||||
|
|
||||||
|
testCase(
|
||||||
|
builder,
|
||||||
|
iw -> iw.addDocuments(docs),
|
||||||
|
stats -> verify.accept(expected, stats),
|
||||||
|
singleton(ft)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testCase(StatsAggregationBuilder builder,
|
||||||
|
CheckedConsumer<RandomIndexWriter, IOException> buildIndex,
|
||||||
|
Consumer<InternalStats> verify,
|
||||||
|
Collection<MappedFieldType> fieldTypes) throws IOException {
|
||||||
try (Directory directory = newDirectory();
|
try (Directory directory = newDirectory();
|
||||||
RandomIndexWriter indexWriter = new RandomIndexWriter(random(), directory)) {
|
RandomIndexWriter indexWriter = new RandomIndexWriter(random(), directory)) {
|
||||||
buildIndex.accept(indexWriter);
|
buildIndex.accept(indexWriter);
|
||||||
try (IndexReader reader = indexWriter.getReader()) {
|
try (IndexReader reader = indexWriter.getReader()) {
|
||||||
IndexSearcher searcher = new IndexSearcher(reader);
|
IndexSearcher searcher = new IndexSearcher(reader);
|
||||||
StatsAggregationBuilder aggBuilder = new StatsAggregationBuilder("my_agg").field("field");
|
final MappedFieldType[] fieldTypesArray = fieldTypes.toArray(new MappedFieldType[0]);
|
||||||
InternalStats stats = search(searcher, new MatchAllDocsQuery(), aggBuilder, ft);
|
final InternalStats stats = search(searcher, new MatchAllDocsQuery(), builder, fieldTypesArray);
|
||||||
verify.accept(stats);
|
verify.accept(stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,6 +450,15 @@ public class StatsAggregatorTests extends AggregatorTestCase {
|
||||||
double max = Long.MIN_VALUE;
|
double max = Long.MIN_VALUE;
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
|
|
||||||
|
SimpleStatsAggregator() {}
|
||||||
|
|
||||||
|
SimpleStatsAggregator(long count, double min, double max, double sum) {
|
||||||
|
this.count = count;
|
||||||
|
this.min = min;
|
||||||
|
this.max = max;
|
||||||
|
this.sum = sum;
|
||||||
|
}
|
||||||
|
|
||||||
void add(double value) {
|
void add(double value) {
|
||||||
count ++;
|
count ++;
|
||||||
if (Double.compare(value, min) < 0) {
|
if (Double.compare(value, min) < 0) {
|
||||||
|
@ -210,4 +470,32 @@ public class StatsAggregatorTests extends AggregatorTestCase {
|
||||||
sum += value;
|
sum += value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<ValuesSourceType> getSupportedValuesSourceTypes() {
|
||||||
|
return singletonList(CoreValuesSourceType.NUMERIC);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldType, String fieldName) {
|
||||||
|
return new StatsAggregationBuilder("_name")
|
||||||
|
.field(fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ScriptService getMockScriptService() {
|
||||||
|
final Map<String, Function<Map<String, Object>, Object>> scripts = org.elasticsearch.common.collect.Map.of(
|
||||||
|
VALUE_SCRIPT_NAME, vars -> ((Number) vars.get("_value")).doubleValue() + 1,
|
||||||
|
FIELD_SCRIPT_NAME, vars -> {
|
||||||
|
final String fieldName = (String) vars.get("field");
|
||||||
|
final LeafDocLookup lookup = (LeafDocLookup) vars.get("doc");
|
||||||
|
return lookup.get(fieldName).stream()
|
||||||
|
.map(value -> ((Number) value).longValue() + 1)
|
||||||
|
.collect(toList());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
final MockScriptEngine engine = new MockScriptEngine(MockScriptEngine.NAME, scripts, emptyMap());
|
||||||
|
final Map<String, ScriptEngine> engines = singletonMap(engine.getType(), engine);
|
||||||
|
return new ScriptService(Settings.EMPTY, engines, ScriptModule.CORE_CONTEXTS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,8 @@ import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static java.util.Collections.emptyMap;
|
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
|
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
|
||||||
import static org.elasticsearch.search.aggregations.AggregationBuilders.filter;
|
import static org.elasticsearch.search.aggregations.AggregationBuilders.filter;
|
||||||
|
@ -86,40 +83,6 @@ public class StatsIT extends AbstractNumericTestCase {
|
||||||
assertThat(Double.isNaN(stats.getAvg()), is(true));
|
assertThat(Double.isNaN(stats.getAvg()), is(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testUnmapped() throws Exception {
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx_unmapped")
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(stats("stats").field("value"))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertShardExecutionState(searchResponse, 0);
|
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(0L));
|
|
||||||
|
|
||||||
Stats stats = searchResponse.getAggregations().get("stats");
|
|
||||||
assertThat(stats, notNullValue());
|
|
||||||
assertThat(stats.getName(), equalTo("stats"));
|
|
||||||
assertThat(stats.getAvg(), equalTo(Double.NaN));
|
|
||||||
assertThat(stats.getMin(), equalTo(Double.POSITIVE_INFINITY));
|
|
||||||
assertThat(stats.getMax(), equalTo(Double.NEGATIVE_INFINITY));
|
|
||||||
assertThat(stats.getSum(), equalTo(0.0));
|
|
||||||
assertThat(stats.getCount(), equalTo(0L));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testPartiallyUnmapped() {
|
|
||||||
Stats s1 = client().prepareSearch("idx")
|
|
||||||
.addAggregation(stats("stats").field("value")).get()
|
|
||||||
.getAggregations().get("stats");
|
|
||||||
Stats s2 = client().prepareSearch("idx", "idx_unmapped")
|
|
||||||
.addAggregation(stats("stats").field("value")).get()
|
|
||||||
.getAggregations().get("stats");
|
|
||||||
assertEquals(s1.getAvg(), s2.getAvg(), 1e-10);
|
|
||||||
assertEquals(s1.getCount(), s2.getCount());
|
|
||||||
assertEquals(s1.getMin(), s2.getMin(), 0d);
|
|
||||||
assertEquals(s1.getMax(), s2.getMax(), 0d);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testSingleValuedField() throws Exception {
|
public void testSingleValuedField() throws Exception {
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||||
|
@ -199,77 +162,6 @@ public class StatsIT extends AbstractNumericTestCase {
|
||||||
assertThat((double) ((InternalAggregation)global).getProperty("stats.count"), equalTo((double) expectedCountValue));
|
assertThat((double) ((InternalAggregation)global).getProperty("stats.count"), equalTo((double) expectedCountValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(stats("stats").field("value"))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertShardExecutionState(searchResponse, 0);
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
|
||||||
|
|
||||||
Stats stats = searchResponse.getAggregations().get("stats");
|
|
||||||
assertThat(stats, notNullValue());
|
|
||||||
assertThat(stats.getName(), equalTo("stats"));
|
|
||||||
assertThat(stats.getAvg(), equalTo((double) (1+2+3+4+5+6+7+8+9+10) / 10));
|
|
||||||
assertThat(stats.getMin(), equalTo(1.0));
|
|
||||||
assertThat(stats.getMax(), equalTo(10.0));
|
|
||||||
assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10));
|
|
||||||
assertThat(stats.getCount(), equalTo(10L));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testSingleValuedFieldWithValueScript() throws Exception {
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(
|
|
||||||
stats("stats")
|
|
||||||
.field("value")
|
|
||||||
.script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + 1", emptyMap())))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertShardExecutionState(searchResponse, 0);
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
|
||||||
|
|
||||||
Stats stats = searchResponse.getAggregations().get("stats");
|
|
||||||
assertThat(stats, notNullValue());
|
|
||||||
assertThat(stats.getName(), equalTo("stats"));
|
|
||||||
assertThat(stats.getAvg(), equalTo((double) (2+3+4+5+6+7+8+9+10+11) / 10));
|
|
||||||
assertThat(stats.getMin(), equalTo(2.0));
|
|
||||||
assertThat(stats.getMax(), equalTo(11.0));
|
|
||||||
assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11));
|
|
||||||
assertThat(stats.getCount(), equalTo(10L));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
|
|
||||||
Map<String, Object> params = new HashMap<>();
|
|
||||||
params.put("inc", 1);
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(
|
|
||||||
stats("stats")
|
|
||||||
.field("value")
|
|
||||||
.script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + inc", params)))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertShardExecutionState(searchResponse, 0);
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
|
||||||
|
|
||||||
Stats stats = searchResponse.getAggregations().get("stats");
|
|
||||||
assertThat(stats, notNullValue());
|
|
||||||
assertThat(stats.getName(), equalTo("stats"));
|
|
||||||
assertThat(stats.getAvg(), equalTo((double) (2+3+4+5+6+7+8+9+10+11) / 10));
|
|
||||||
assertThat(stats.getMin(), equalTo(2.0));
|
|
||||||
assertThat(stats.getMax(), equalTo(11.0));
|
|
||||||
assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11));
|
|
||||||
assertThat(stats.getCount(), equalTo(10L));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testMultiValuedField() throws Exception {
|
public void testMultiValuedField() throws Exception {
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||||
|
@ -291,157 +183,6 @@ public class StatsIT extends AbstractNumericTestCase {
|
||||||
assertThat(stats.getCount(), equalTo(20L));
|
assertThat(stats.getCount(), equalTo(20L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testMultiValuedFieldWithValueScript() throws Exception {
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(
|
|
||||||
stats("stats")
|
|
||||||
.field("values")
|
|
||||||
.script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertShardExecutionState(searchResponse, 0);
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
|
||||||
|
|
||||||
Stats stats = searchResponse.getAggregations().get("stats");
|
|
||||||
assertThat(stats, notNullValue());
|
|
||||||
assertThat(stats.getName(), equalTo("stats"));
|
|
||||||
assertThat(stats.getAvg(), equalTo((double) (1+2+3+4+5+6+7+8+9+10+2+3+4+5+6+7+8+9+10+11) / 20));
|
|
||||||
assertThat(stats.getMin(), equalTo(1.0));
|
|
||||||
assertThat(stats.getMax(), equalTo(11.0));
|
|
||||||
assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10+2+3+4+5+6+7+8+9+10+11));
|
|
||||||
assertThat(stats.getCount(), equalTo(20L));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
|
|
||||||
Map<String, Object> params = new HashMap<>();
|
|
||||||
params.put("dec", 1);
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(
|
|
||||||
stats("stats")
|
|
||||||
.field("values")
|
|
||||||
.script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params)))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertShardExecutionState(searchResponse, 0);
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
|
||||||
|
|
||||||
Stats stats = searchResponse.getAggregations().get("stats");
|
|
||||||
assertThat(stats, notNullValue());
|
|
||||||
assertThat(stats.getName(), equalTo("stats"));
|
|
||||||
assertThat(stats.getAvg(), equalTo((double) (1+2+3+4+5+6+7+8+9+10+2+3+4+5+6+7+8+9+10+11) / 20));
|
|
||||||
assertThat(stats.getMin(), equalTo(1.0));
|
|
||||||
assertThat(stats.getMax(), equalTo(11.0));
|
|
||||||
assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10+2+3+4+5+6+7+8+9+10+11));
|
|
||||||
assertThat(stats.getCount(), equalTo(20L));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testScriptSingleValued() throws Exception {
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(
|
|
||||||
stats("stats")
|
|
||||||
.script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", emptyMap())))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertShardExecutionState(searchResponse, 0);
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
|
||||||
|
|
||||||
Stats stats = searchResponse.getAggregations().get("stats");
|
|
||||||
assertThat(stats, notNullValue());
|
|
||||||
assertThat(stats.getName(), equalTo("stats"));
|
|
||||||
assertThat(stats.getAvg(), equalTo((double) (1+2+3+4+5+6+7+8+9+10) / 10));
|
|
||||||
assertThat(stats.getMin(), equalTo(1.0));
|
|
||||||
assertThat(stats.getMax(), equalTo(10.0));
|
|
||||||
assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10));
|
|
||||||
assertThat(stats.getCount(), equalTo(10L));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testScriptSingleValuedWithParams() throws Exception {
|
|
||||||
Map<String, Object> params = new HashMap<>();
|
|
||||||
params.put("inc", 1);
|
|
||||||
|
|
||||||
Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value + inc", params);
|
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(stats("stats").script(script))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertShardExecutionState(searchResponse, 0);
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
|
||||||
|
|
||||||
Stats stats = searchResponse.getAggregations().get("stats");
|
|
||||||
assertThat(stats, notNullValue());
|
|
||||||
assertThat(stats.getName(), equalTo("stats"));
|
|
||||||
assertThat(stats.getAvg(), equalTo((double) (2+3+4+5+6+7+8+9+10+11) / 10));
|
|
||||||
assertThat(stats.getMin(), equalTo(2.0));
|
|
||||||
assertThat(stats.getMax(), equalTo(11.0));
|
|
||||||
assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11));
|
|
||||||
assertThat(stats.getCount(), equalTo(10L));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testScriptMultiValued() throws Exception {
|
|
||||||
Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['values']", emptyMap());
|
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(stats("stats").script(script))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertShardExecutionState(searchResponse, 0);
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
|
||||||
|
|
||||||
Stats stats = searchResponse.getAggregations().get("stats");
|
|
||||||
assertThat(stats, notNullValue());
|
|
||||||
assertThat(stats.getName(), equalTo("stats"));
|
|
||||||
assertThat(stats.getAvg(), equalTo((double) (2+3+4+5+6+7+8+9+10+11+3+4+5+6+7+8+9+10+11+12) / 20));
|
|
||||||
assertThat(stats.getMin(), equalTo(2.0));
|
|
||||||
assertThat(stats.getMax(), equalTo(12.0));
|
|
||||||
assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11+3+4+5+6+7+8+9+10+11+12));
|
|
||||||
assertThat(stats.getCount(), equalTo(20L));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testScriptMultiValuedWithParams() throws Exception {
|
|
||||||
Map<String, Object> params = new HashMap<>();
|
|
||||||
params.put("dec", 1);
|
|
||||||
|
|
||||||
Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "[ doc['value'].value, doc['value'].value - dec ]",
|
|
||||||
params);
|
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addAggregation(
|
|
||||||
stats("stats")
|
|
||||||
.script(script))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertShardExecutionState(searchResponse, 0);
|
|
||||||
|
|
||||||
assertHitCount(searchResponse, 10);
|
|
||||||
|
|
||||||
Stats stats = searchResponse.getAggregations().get("stats");
|
|
||||||
assertThat(stats, notNullValue());
|
|
||||||
assertThat(stats.getName(), equalTo("stats"));
|
|
||||||
assertThat(stats.getAvg(), equalTo((double) (1+2+3+4+5+6+7+8+9+10+0+1+2+3+4+5+6+7+8+9) / 20));
|
|
||||||
assertThat(stats.getMin(), equalTo(0.0));
|
|
||||||
assertThat(stats.getMax(), equalTo(10.0));
|
|
||||||
assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10+0+1+2+3+4+5+6+7+8+9));
|
|
||||||
assertThat(stats.getCount(), equalTo(20L));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testOrderByEmptyAggregation() throws Exception {
|
public void testOrderByEmptyAggregation() throws Exception {
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||||
|
|
|
@ -164,34 +164,6 @@ public class SumIT extends AbstractNumericTestCase {
|
||||||
assertThat((double) ((InternalAggregation)sum).getProperty("value"), equalTo(expectedSumValue));
|
assertThat((double) ((InternalAggregation)sum).getProperty("value"), equalTo(expectedSumValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This test has been moved to {@link SumAggregatorTests#testPartiallyUnmapped()} */
|
|
||||||
@Override
|
|
||||||
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {}
|
|
||||||
|
|
||||||
/** this test has been moved to {@link SumAggregatorTests#testValueScriptSingleValuedField()} */
|
|
||||||
@Override
|
|
||||||
public void testSingleValuedFieldWithValueScript() throws Exception {}
|
|
||||||
|
|
||||||
/** this test has been moved to {@link SumAggregatorTests#testValueScriptSingleValuedField()} */
|
|
||||||
@Override
|
|
||||||
public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {}
|
|
||||||
|
|
||||||
/** this test has been moved to {@link SumAggregatorTests#testFieldScriptSingleValuedField()} */
|
|
||||||
@Override
|
|
||||||
public void testScriptSingleValued() throws Exception {}
|
|
||||||
|
|
||||||
/** this test has been moved to {@link SumAggregatorTests#testFieldScriptSingleValuedField()} */
|
|
||||||
@Override
|
|
||||||
public void testScriptSingleValuedWithParams() throws Exception {}
|
|
||||||
|
|
||||||
/** this test has been moved to {@link SumAggregatorTests#testFieldScriptMultiValuedField()} */
|
|
||||||
@Override
|
|
||||||
public void testScriptMultiValued() throws Exception {}
|
|
||||||
|
|
||||||
/** this test has been moved to {@link SumAggregatorTests#testFieldScriptMultiValuedField()} */
|
|
||||||
@Override
|
|
||||||
public void testScriptMultiValuedWithParams() throws Exception {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testMultiValuedField() throws Exception {
|
public void testMultiValuedField() throws Exception {
|
||||||
|
|
||||||
|
@ -208,14 +180,6 @@ public class SumIT extends AbstractNumericTestCase {
|
||||||
assertThat(sum.getValue(), equalTo((double) 2+3+3+4+4+5+5+6+6+7+7+8+8+9+9+10+10+11+11+12));
|
assertThat(sum.getValue(), equalTo((double) 2+3+3+4+4+5+5+6+6+7+7+8+8+9+9+10+10+11+11+12));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** this test has been moved to {@link SumAggregatorTests#testValueScriptMultiValuedField()} */
|
|
||||||
@Override
|
|
||||||
public void testMultiValuedFieldWithValueScript() throws Exception {}
|
|
||||||
|
|
||||||
/** this test has been moved to {@link SumAggregatorTests#testValueScriptMultiValuedField()} */
|
|
||||||
@Override
|
|
||||||
public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testOrderByEmptyAggregation() throws Exception {
|
public void testOrderByEmptyAggregation() throws Exception {
|
||||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||||
|
|
|
@ -67,33 +67,33 @@ public abstract class AbstractNumericTestCase extends ESIntegTestCase {
|
||||||
ensureSearchable();
|
ensureSearchable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void testEmptyAggregation() throws Exception;
|
public void testEmptyAggregation() throws Exception {}
|
||||||
|
|
||||||
public abstract void testUnmapped() throws Exception;
|
public void testUnmapped() throws Exception {}
|
||||||
|
|
||||||
public abstract void testSingleValuedField() throws Exception;
|
public void testSingleValuedField() throws Exception {}
|
||||||
|
|
||||||
public abstract void testSingleValuedFieldGetProperty() throws Exception;
|
public void testSingleValuedFieldGetProperty() throws Exception {}
|
||||||
|
|
||||||
public abstract void testSingleValuedFieldPartiallyUnmapped() throws Exception;
|
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {}
|
||||||
|
|
||||||
public abstract void testSingleValuedFieldWithValueScript() throws Exception;
|
public void testSingleValuedFieldWithValueScript() throws Exception {}
|
||||||
|
|
||||||
public abstract void testSingleValuedFieldWithValueScriptWithParams() throws Exception;
|
public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {}
|
||||||
|
|
||||||
public abstract void testMultiValuedField() throws Exception;
|
public void testMultiValuedField() throws Exception {}
|
||||||
|
|
||||||
public abstract void testMultiValuedFieldWithValueScript() throws Exception;
|
public void testMultiValuedFieldWithValueScript() throws Exception {}
|
||||||
|
|
||||||
public abstract void testMultiValuedFieldWithValueScriptWithParams() throws Exception;
|
public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {}
|
||||||
|
|
||||||
public abstract void testScriptSingleValued() throws Exception;
|
public void testScriptSingleValued() throws Exception {}
|
||||||
|
|
||||||
public abstract void testScriptSingleValuedWithParams() throws Exception;
|
public void testScriptSingleValuedWithParams() throws Exception {}
|
||||||
|
|
||||||
public abstract void testScriptMultiValued() throws Exception;
|
public void testScriptMultiValued() throws Exception {}
|
||||||
|
|
||||||
public abstract void testScriptMultiValuedWithParams() throws Exception;
|
public void testScriptMultiValuedWithParams() throws Exception {}
|
||||||
|
|
||||||
public abstract void testOrderByEmptyAggregation() throws Exception;
|
public void testOrderByEmptyAggregation() throws Exception {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue