Delete document without id?


#1

So my current code to delete some specific "documents" is failing. I get a message that:

Unable to build a path with those params. Supply at least index, type, id

I have elasticsearch creating my ids for me, so I don't really know what they are. The only way I can come up with knowing them, is to query with the criteria I am trying to use for the delete, and create an array of ids then use that array to delete specific ids. Is that the only way to get this done? Here is a snippit of the code I am attempting right now (not working). Note: the date field is a string, not a timestamp.

elastic.delete({
                index: MONTHLY_SUMMARY_INDEX,
                type: "object",
                body: {
                    query: {
                        match: {
                            date: namedMonthYear
                        }
                    }
                }
            }).then(function(res) {

(Yannick Welsch) #2

The delete-by-query plugin will help:

https://www.elastic.co/guide/en/elasticsearch/plugins/current/delete-by-query-usage.html


(system) #3