Elastic search query after update returning old non updated document

I am updating a document in my index where I am changing its status from 0 to 1. When I do an update and again query for any document having status 0, it again returns the same document, so I end up doing the same thing again. This operation gets repeated twice or thrice randomly. There seems to be some lag on part of elastic search client because if I do the same operation with a settimeout, it doesn't repeat. This problem gets magnified when I update a say 5000 documents, which runs around 5500 times on an average.

function getData(){
client.search({
index: 'es_dummy',
type: 'log',
size: 1,
body: {
"query" : {
"match" : {
"status" : "0"
}
}
}
},
function(err, resp){
console.log(resp.hits.hits.length);
if(resp.hits.hits.length)
updateIndexData(resp.hits.hits, 0, resp.hits.hits.length);
else
console.log("done");
});
}
getData();
function updateIndexData(resp, index, length){
client.update({
index: 'es_dummy',
type: 'log',
id: resp[index]._id,
script: 'ctx._source.status = 1'
},
function(err1, resp1){
if(!err1 && resp1){
console.log("updated" + " " + update);
var milliseconds = (new Date).getTime();
console.log("time " + milliseconds);
update++;
getData();
}
else
console.log(err1);
})

}