Skip to content

Latest commit

 

History

History
87 lines (68 loc) · 1.29 KB

delete.rst

File metadata and controls

87 lines (68 loc) · 1.29 KB

DELETE Statement

Table of contents

DELETE statement deletes documents that satisfy the predicates in WHERE clause. Note that all documents are deleted in the case of WHERE clause absent.

Rule singleDeleteStatement:

/docs/user/img/rdd/singleDeleteStatement.png

The datarows field in this case shows rows impacted, in other words how many documents were just deleted.

SQL query:

POST /_plugins/_sql
{
  "query" : """
        DELETE FROM accounts
        WHERE age > 30
        """
}

Explain:

{
  "size" : 1000,
  "query" : {
    "bool" : {
      "must" : [
        {
          "range" : {
            "age" : {
              "from" : 30,
              "to" : null,
              "include_lower" : false,
              "include_upper" : true,
              "boost" : 1.0
            }
          }
        }
      ],
      "adjust_pure_negative" : true,
      "boost" : 1.0
    }
  },
  "_source" : false
}

Result set:

{
  "schema" : [
    {
      "name" : "deleted_rows",
      "type" : "long"
    }
  ],
  "total" : 1,
  "datarows" : [
    [
      3
    ]
  ],
  "size" : 1,
  "status" : 200
}