I am trying to delete specific date records from Elasticsearch. My query is the following:
curl -XDELETE 'http://localhost:9200/twitter/twit/_query' -d '
{
"filter" : {
"range" : {
"date_time" : { "from" : "2012-10-01 00:00:01", "to" : "2013-05-01 11:59:59"}
}
}
}'
but it is not deleting any records. so it is correct one or are there some other methods to delete records.
You use DELETE to remove a document from an index. You must specify the index name and document ID. You cannot send deletion requests directly to a data stream. To delete a document in a data stream, you must target the backing index containing the document.
The ID of the document to delete. Only perform the delete operation if the document's version number matches the specified number. Only perform the delete operation if the document has the specified primary term. If true, OpenSearch refreshes shards to make the delete operation available to search results.
To delete the index, you must roll over the data stream so a new write index is created. You can then use the delete index API to delete the previous write index.
Yes, deleting the index, deletes all the data in that index.
Prior to 1.0, the delete by query does not use filters. The syntax goes directly to what is the "query" block in the search API. You need to use the range query instead.
curl -XDELETE 'http://localhost:9200/twitter/twit/_query' -d '
{
"range" : {
"date_time" : { "from" : "2012-10-01 00:00:01", "to" : "2013-05-01 11:59:59"}
}
}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With