0

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 ...

4
  • yes, and when I remove the delete I can see it again!!! Commented Jun 20, 2016 at 10:30
  • result of the console.log undefined for all users ... Commented Jun 20, 2016 at 10:34
  • and when I console.log(user) I see the address.full !!!!!!!!!!!!! i'm going crazy ... Commented Jun 20, 2016 at 10:36
  • Can you post the result what you got from elasticsearch?? Commented Jun 20, 2016 at 10:46

1 Answer 1

1

are you reindexing your elasticsearch data after you delete? the indexed record may persist even though you have removed the document from disk

more on this can be read @ https://www.elastic.co/guide/en/elasticsearch/guide/current/update-doc.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.