use of org.apache.lucene.document.SortedNumericDocValuesField in project elasticsearch by elastic.
the class MaxAggregatorTests method testSomeMatchesSortedNumericDocValues.
public void testSomeMatchesSortedNumericDocValues() throws IOException {
testCase(new FieldValueQuery("number"), iw -> {
iw.addDocument(singleton(new SortedNumericDocValuesField("number", 7)));
iw.addDocument(singleton(new SortedNumericDocValuesField("number", 1)));
}, max -> {
assertEquals(7, max.getValue(), 0);
});
}
use of org.apache.lucene.document.SortedNumericDocValuesField in project elasticsearch by elastic.
the class StatsAggregatorTests method testRandomLongs.
public void testRandomLongs() throws IOException {
MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.LONG);
ft.setName("field");
final SimpleStatsAggregator expected = new SimpleStatsAggregator();
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.sum, stats.getSum(), TOLERANCE);
assertEquals(expected.min, stats.getMin(), 0);
assertEquals(expected.max, stats.getMax(), 0);
assertEquals(expected.sum / expected.count, stats.getAvg(), TOLERANCE);
});
}
use of org.apache.lucene.document.SortedNumericDocValuesField in project elasticsearch by elastic.
the class AvgAggregatorTests method testSomeMatchesSortedNumericDocValues.
public void testSomeMatchesSortedNumericDocValues() throws IOException {
testCase(new FieldValueQuery("number"), iw -> {
iw.addDocument(singleton(new SortedNumericDocValuesField("number", 7)));
iw.addDocument(singleton(new SortedNumericDocValuesField("number", 2)));
iw.addDocument(singleton(new SortedNumericDocValuesField("number", 3)));
}, avg -> {
assertEquals(4, avg.getValue(), 0);
});
}
use of org.apache.lucene.document.SortedNumericDocValuesField in project elasticsearch by elastic.
the class ValueCountAggregatorTests method testSomeMatchesSortedNumericDocValues.
public void testSomeMatchesSortedNumericDocValues() throws IOException {
testCase(new FieldValueQuery(FIELD_NAME), ValueType.NUMERIC, iw -> {
iw.addDocument(singleton(new SortedNumericDocValuesField("wrong_number", 7)));
iw.addDocument(singleton(new SortedNumericDocValuesField(FIELD_NAME, 7)));
iw.addDocument(singleton(new SortedNumericDocValuesField(FIELD_NAME, 1)));
}, count -> assertEquals(2L, count.getValue()));
}
use of org.apache.lucene.document.SortedNumericDocValuesField in project elasticsearch by elastic.
the class ValueCountAggregatorTests method testNoMatchingField.
public void testNoMatchingField() throws IOException {
testCase(new MatchAllDocsQuery(), ValueType.LONG, iw -> {
iw.addDocument(singleton(new SortedNumericDocValuesField("wrong_number", 7)));
iw.addDocument(singleton(new SortedNumericDocValuesField("wrong_number", 1)));
}, count -> assertEquals(0L, count.getValue()));
}
Aggregations