LastModifiedDate is not getting updated for an entity using spring-data-elasticsearch

Viewed 211

// Entity model definition

@Builder.Default
@LastModifiedDate
@Field(type = FieldType.Date, name = "modified_dt", format = DateFormat.basic_date_time)
private Instant modifiedDate = Instant.now();

// update attribute call

protected void updateAttribute(String id, Document document) throws Exception {
    UpdateQuery updateQuery = UpdateQuery.builder(id).withDocument(document).build();
    UpdateResponse updateResponse = operations.update(updateQuery, indexCoordinates());
    Result result = updateResponse.getResult();
    if (!result.equals(Result.UPDATED)) {
        throw new Exception();
    }
}
1 Answers
Related