node.js - An Elastic search deletebyquery equivalent to this mysql query "delete from item_img where datediff(now(), date) > 5" -
please searching elastic search deletebyquery equivalent mysql query "delete item_img datediff(now(), date) > 5"
here code doesn't work
function osas(){`enter code here` client.deletebyquery({ index: 'lostit', type: 'string', body: { "query": { "range" : { "date" : { "gt": "now+20m" } } } } }, function(err, res) { if (err) { console.error(err.message); } else { console.log('indexes have been deleted!'); } }); } osas();
//it written based on nodejs connector elasticearch
i think figured out anyways..using concept of inequality equation in math
function osas(){`enter code here` client.deletebyquery({ index: 'lostit', type: 'string', body: { "query": { "range" : { "date" : { "lte": "now-5d" } } } } }, function(err, res) { if (err) { console.error(err.message); } else { console.log('indexes have been deleted!'); } }); } osas();
Comments
Post a Comment