EDIT:
To clarify, the question is "how do I write a query for documents that are X days old so I can delete them".
END OF EDIT
Our code indexes results from a query using ElasticSearch. We want to run a clean up job once a day to delete all old documents. We currently do so by calling an external script, but to cut down on the dependencies we would love to do it from Java.
I can't figure out how to query for the old documents using the API... Clues, help?
If you delete documents which have been stored for a certain amount of time you can set a TTL (time-to-live) parameter, setting the documents deletion bit-set flag once this time has elapsed. See here. Hope this is an alternative you could consider.
UPDATE
"query":{
"match_all": {}
},
"filter":{
range:{
"field":{
lte: 20140225,
gte: 20140201
}
}
}