I am using spring data elasticserch to persist the documents into elasticsearch. Following is my document structure:
@Id
private String id;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
@Field(type = FieldType.Date, format = DateFormat.basic_date, index = FieldIndex.not_analyzed)
@CreatedDate
private DateTime createdDateTime;
@JsonIgnore
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
@Field(type = FieldType.Date, format = DateFormat.basic_date, index = FieldIndex.not_analyzed)
private DateTime deletedDateTime;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
@Field(type = FieldType.Date, format = DateFormat.basic_date, index = FieldIndex.not_analyzed)
@LastModifiedDate
private DateTime modifiedDateTime;
@Field(index = FieldIndex.not_analyzed)
private DataSource dataSource;
I am using @CreatedDate and @LastModifiedDate annotations to store created and modified dates respectively. However, when the documents get stored, createdDateTime
and modifiedDateTime
are stored as null and no error is thrown.
Do I need to make any further changes to make this work? Please note that the same structure works when I try to store documents in mongo.
Thanks in advance.