Skip to content

On deleting data with ElasticSearchrestTemplate delete or doDelete method #1835

@zhushuaiCoding

Description

@zhushuaiCoding

Regarding the ElasticSearchrestTemplate delete or doDelete method to delete data, if there is no data, then ID is also returned, which should be a bug. If there is no data, ID should not be returned, so it is not known whether the data has been deleted. Can you provide a method to return the deleteresponse object and let the developer judge it by himself.
Solution:
protected DeleteResponse doDeleteResponse(String id, @nullable String routing, IndexCoordinates index) {
Assert.notNull(id, "id must not be null");
Assert.notNull(index, "index must not be null");
DeleteRequest request = prepareWriteRequest(
requestFactory.deleteRequest(elasticsearchConverter.convertId(id), routing, index));
return execute(client -> client.delete(request, RequestOptions.DEFAULT));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions