You can
delete a document using DELETE request.
GET
xyz/employees/1
Above
request gets following document.
{
"_index": "xyz",
"_type": "employees",
"_id": "1",
"_version": 6,
"found": true,
"_source": {
"firstName": "Sunil Kumar",
"lastName": "Kumar",
"age": 36
}
}
DELETE
xyz/employees/1
Above
request deletes document and give following response.
{
"found": true,
"_index": "xyz",
"_type": "employees",
"_id": "1",
"_version": 7
}
Try to
delete the document again. You will get following kind of response.
{
"found": false,
"_index": "xyz",
"_type": "employees",
"_id": "1",
"_version": 8
}
As you
observe version number is getting incremented every time, you request for
DELETE operation. This is part of internal book keeping.
Note:
DELETE
operation will not delete the document immediately. Elastic search mark the
document as to be deleted, it deletes the documents in some time.
No comments:
Post a Comment