DoubleMapper extends SingleColumnMapper.SingleFieldMapper<Double> { @Override public Optional<Field> sortedField(String name, Double value) { long sortable = NumericUtils.doubleToSortableLong(value); return Optional.of(new SortedNumericDocValuesField(name, sortable)); } DoubleMapper(String field, String column, Boolean validated, Float boost); @Override Optional<Field> indexedField(String name, Double value); @Override Optional<Field> sortedField(String name, Double value); @Override SortField sortField(String name, boolean reverse); @Override String toString(); static final float DEFAULT_BOOST; final Float boost; }
@Test public void testSortedField() { DoubleMapper mapper = doubleMapper().boost(1f).build("field"); Field field = mapper.sortedField("name", 3.2d) .orElseThrow(() -> new AssertionError("Sorted field is not created")); assertEquals("Sorted field type is wrong", DocValuesType.SORTED_NUMERIC, field.fieldType().docValuesType()); }