I am new to Elasticsearch and trying to figure out a way to delete a document that contains a field with timestamp as its value.
I have a document with a field called lastmodifiedtime . This field is of type long and is being used to store the timestamp (ie number of milliseconds since EPOCH. ex, 1486709502).
Now I have a usecase where I need to delete all the documents that are having lastmodifiedtime older than one day. So I find out the timstamp value corresponding to the one day older time and then try to delete the documents.
I tried REST call as below
DELETE http://localhost:9200/testindex/testtype/_query
"query": {
"term" : {
"lastmodifiedtime" : {
"lte": 1486709504
}
}
}
But getting the following response:
{
"found": false,
"_index": "testindex",
"_type": "testtype",
"_id": "_query",
"_version": 4,
"result": "not_found",
"_shards":
{
"total": 2,
"successful": 1,
"failed": 0
}
}
Could you please help me how to deal with this scenario?
you can use delete_by query api
POST http://localhost:9200/testindex/testtype/_delete_by_query
{
"query": {
"range": {
"lastmodifiedtime": {
"lte": 1486709504
}
}
}
}
Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.