DoubleMapper extends SingleColumnMapper.SingleFieldMapper<Double> { @Override public Optional<Field> indexedField(String name, Double value) { DoubleField doubleField = new DoubleField(name, value, STORE); doubleField.setBoost(boost); return Optional.of(doubleField); } 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 testIndexedField() { DoubleMapper mapper = doubleMapper().boost(1f).build("field"); Field field = mapper.indexedField("name", 3.2d) .orElseThrow(() -> new AssertionError("Indexed field is not created")); assertEquals("Indexed field value is wrong", 3.2d, field.numericValue()); assertEquals("Indexed field name is wrong", "name", field.name()); assertEquals("Indexed field type is wrong", false, field.fieldType().stored()); }