I'm trying to delete and object from my Elasticsearch result query, but this object persist whatever I do:
Here is my code :
exports.searchUserByKeyWord = (req, res) => {
User.search(byKeyWordQuery(req), geoDistance(), (err, users) => {
if (err) requestError(res, err)
let result = []
for(let user of users.hits.hits) {
delete user.address.full
result.push(user)
}
sendJsonResponse(res, 200, result)
})
}
Like you can see I'm using delete but it doesn't work, what I can't understand here is the fact that when I replace sendJsonResponse(res, 200, result) with
sendJsonResponse(res, 200, result[0].address.full) I found out that this address got successfully deleted, but when I test my API with Postman without adding result[0].address.full the address full field is still there ...