Search code examples
springelasticsearchspring-data-elasticsearch

Unable to find "UpdateQueryBuilder" in springframework data 4


I am upgrading spring elasticsearch data from 3.x to 4.2.1. The support of UpdateQueryBuilder is removed from the latest version which earlier I used to construct UpdateQuery from UpdateRequest object of elasticsearch. For example:

        return new UpdateQueryBuilder()
              .withId(documentId)
              .withClass(getDocumentClass())
              .withUpdateRequest(updateRequest)
              .build();

The new class UpdateQuery doesn't accept UpdateRequest object but only accepts Query. I would prefer to avoid UpdateRequest conversion to Query somehow.

Does anyone have suggestions on how to make UpdateQuery and UpdateRequest work together?


Solution

  • After the change from 3.2.x to 4.0 a year ago Spring Data Elasticsearch does not accept Elasticsearch classes as parameters to the API in order to constantly abstract away Elasticsearch implementation details from the SDE user.

    From 4.0 on there is the nested UpdateQuery.Builder class on which you should be able to set all the parameters you did previously on the org.elasticsearch.action.update.UpdateRequest class.