LongMapper extends SingleColumnMapper.SingleFieldMapper<Long> { @Override public Optional<Field> indexedField(String name, Long value) { LongField longField = new LongField(name, value, STORE); longField.setBoost(boost); return Optional.of(longField); } LongMapper(String field, String column, Boolean validated, Float boost); @Override Optional<Field> indexedField(String name, Long value); @Override Optional<Field> sortedField(String name, Long value); @Override SortField sortField(String name, boolean reverse); @Override String toString(); static final Float DEFAULT_BOOST; final Float boost; }
@Test public void testIndexedField() { LongMapper mapper = longMapper().boost(1f).build("field"); Field field = mapper.indexedField("name", 3L) .orElseThrow(() -> new AssertionError("Indexed field is not created")); assertEquals("Indexed field value is wrong", 3L, field.numericValue()); assertEquals("Indexed field name is wrong", "name", field.name()); assertFalse("Indexed field type is wrong", field.fieldType().stored()); }