use of org.elasticsearch.index.mapper.MappedFieldType in project elasticsearch by elastic.
the class UidFieldTypeTests method testRangeQuery.
public void testRangeQuery() {
MappedFieldType ft = createDefaultFieldType();
ft.setName("_uid");
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> ft.rangeQuery(null, null, randomBoolean(), randomBoolean(), null));
assertEquals("Field [_uid] of type [_uid] does not support range queries", e.getMessage());
}
use of org.elasticsearch.index.mapper.MappedFieldType in project elasticsearch by elastic.
the class FieldMaskingSpanQueryBuilderTests method doAssertLuceneQuery.
@Override
protected void doAssertLuceneQuery(FieldMaskingSpanQueryBuilder queryBuilder, Query query, SearchContext context) throws IOException {
String fieldInQuery = queryBuilder.fieldName();
MappedFieldType fieldType = context.getQueryShardContext().fieldMapper(fieldInQuery);
if (fieldType != null) {
fieldInQuery = fieldType.name();
}
assertThat(query, instanceOf(FieldMaskingSpanQuery.class));
FieldMaskingSpanQuery fieldMaskingSpanQuery = (FieldMaskingSpanQuery) query;
assertThat(fieldMaskingSpanQuery.getField(), equalTo(fieldInQuery));
assertThat(fieldMaskingSpanQuery.getMaskedQuery(), equalTo(queryBuilder.innerQuery().toQuery(context.getQueryShardContext())));
}
use of org.elasticsearch.index.mapper.MappedFieldType in project elasticsearch by elastic.
the class ExtendedStatsAggregatorTests method testEmpty.
public void testEmpty() throws IOException {
MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.LONG);
ft.setName("field");
testCase(ft, iw -> {
}, 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);
assertEquals(Double.NaN, stats.getVariance(), 0);
assertEquals(Double.NaN, stats.getStdDeviation(), 0);
assertEquals(0d, stats.getSumOfSquares(), 0);
});
}
use of org.elasticsearch.index.mapper.MappedFieldType in project elasticsearch by elastic.
the class ExtendedStatsAggregatorTests method testRandomDoubles.
public void testRandomDoubles() throws IOException {
MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.DOUBLE);
ft.setName("field");
final ExtendedSimpleStatsAggregator expected = new ExtendedSimpleStatsAggregator();
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++) {
double value = randomDoubleBetween(-100d, 100d, true);
long valueAsLong = NumericUtils.doubleToSortableLong(value);
doc.add(new SortedNumericDocValuesField("field", valueAsLong));
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);
assertEquals(expected.sumOfSqrs, stats.getSumOfSquares(), TOLERANCE);
assertEquals(expected.stdDev(), stats.getStdDeviation(), TOLERANCE);
assertEquals(expected.variance(), stats.getVariance(), TOLERANCE);
assertEquals(expected.stdDevBound(ExtendedStats.Bounds.LOWER, stats.getSigma()), stats.getStdDeviationBound(ExtendedStats.Bounds.LOWER), TOLERANCE);
assertEquals(expected.stdDevBound(ExtendedStats.Bounds.UPPER, stats.getSigma()), stats.getStdDeviationBound(ExtendedStats.Bounds.UPPER), TOLERANCE);
});
}
use of org.elasticsearch.index.mapper.MappedFieldType in project elasticsearch by elastic.
the class ExtendedStatsAggregatorTests method testRandomLongs.
public void testRandomLongs() throws IOException {
MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.LONG);
ft.setName("field");
final ExtendedSimpleStatsAggregator expected = new ExtendedSimpleStatsAggregator();
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);
assertEquals(expected.sumOfSqrs, stats.getSumOfSquares(), TOLERANCE);
assertEquals(expected.stdDev(), stats.getStdDeviation(), TOLERANCE);
assertEquals(expected.variance(), stats.getVariance(), TOLERANCE);
assertEquals(expected.stdDevBound(ExtendedStats.Bounds.LOWER, stats.getSigma()), stats.getStdDeviationBound(ExtendedStats.Bounds.LOWER), TOLERANCE);
assertEquals(expected.stdDevBound(ExtendedStats.Bounds.UPPER, stats.getSigma()), stats.getStdDeviationBound(ExtendedStats.Bounds.UPPER), TOLERANCE);
});
}
Aggregations