How to store height information as a float in spring-data-elasticsearch. My data model looks like this
Height.java
int feet, inches;
@Document(indexName = "users", shards = 1, versionType = VersionType.INTERNAL, createIndex = true)
public class User implements Persistable<String> {
private Height height;
}
FloatConverter seems to work
@WritingConverter
public enum ToFloatConverter implements Converter<Height, Float> {
INSTANCE;
@Override
public Float convert(Height height) {
String heightStr = height.getFeet() + "." + height.getInches();
return Float.parseFloat(heightStr);
}
}