Reputation: 103
I am trying to create a query that will give me accounts that was created before a certain future date. I would like delete those account that were created 30 days before that future date. I am not sure how to write that range. Currently I have a query that gives me account that was created 30 days before today.
range: {
updatedAt: {
lte: "now-2592000/s",
},
},
Some guidance will be highly appreciated.
Upvotes: 0
Views: 273
Reputation: 9099
You can use _delete_by_query
POST <index-name>/_delete_by_query
{
"query": {
"range": {
"createdAt": {
"lte": "2022-10-31||-30d" --> any future date
}
}
}
}
Pass any date with "||" at end.
My createdAt field is indexed using type "date"
Upvotes: 2