Can't figure out must_not in filtered DELETE query

(Marcel Emblazoned) #1

I am trying to delete a set of documents that do not match a field with a certain value by sending the following data through a DELETE request to "localhost:9200/products/phone":


  "query": {
    "filtered": {
      "query": {
        "match_all": []
      "filter": {
        "bool": {
          "must": [],
          "should": [],
          "must_not": {
            "term": {
              "batch": 1433585920

But this query ends up deleting ALL documents of the /products/phone type, including the documents that have the 1433586041 value in 'batch'. What am I doing wrong?

(Colin Goodheart-Smithe) #2

Looks like your URL is wrong for a delete by query request. It should be in the format:


see the following documentation link for more details ont the delete by query API:

(Dan Tuffery) #3

The URI in your delete by query request is not correct.

This will delete all documents of type phone. You need to specify the _query endpoint, i.e.


More examples can be found here.

(system) #4