Spring Data Elasticsearch @Field
Spring Data Elasticsearch @Field
The @Field annotation now supports nearly all of the types that can be used in Elasticsearch.@Document(indexName = "person", type = "dummy")
public class Person implements Persistable<Long> {
@Nullable @Id
private Long id;
@Nullable @Field(value = "last-name", type = FieldType.Text, fielddata = true)
private String lastName; (1)
@Nullable @Field(name = "birth-date", type = FieldType.Date, format = DateFormat.basic_date)
private LocalDate birthDate; (2)
@CreatedDate
@Nullable @Field(type = FieldType.Date, format = DateFormat.basic_date_time)
private Instant created; (3)
// other properties, getter, setter
}
- in Elasticsearch this field will be named last-name, this mapping is handled transparently
- a property for a date without time information
- another property this time with full date and time information
Comments
Post a Comment