apoc.es.delete

Procedure Apoc Extended

apoc.es.delete(host-or-key,index-or-null,type-or-null,id-or-null,query-or-null,$config) yield value - perform a DELETE operation on elastic search

Signature

apoc.es.delete(host :: STRING?, index :: STRING?, type :: STRING?, id :: STRING?, query :: ANY?, config = {} :: MAP?) :: (value :: MAP?)

Input parameters

Name Type Default

host

STRING?

null

index

STRING?

null

type

STRING?

null

id

STRING?

null

query

ANY?

null

payload

ANY?

null

config

MAP?

{}

Output parameters

Name Type

value

MAP?

Usage Examples

The examples in this section are based on the following Elastic instance:

version: '3.5'
services:
  elastic:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
    ports:
      - 9200:9200
      - 9300:9300
    environment:
      - discovery.type=single-node

with a dataset created by downloading this file, and executing the command:

curl -H 'Content-Type: application/json' -XPOST 'localhost:9200/bank/_bulk?pretty&refresh' --data-binary '@accounts.json'

We can delete the document with id 1, by running the following query:

CALL apoc.es.delete("localhost","bank","_doc","1");
Table 1. Results
value
{
  "result": "deleted",
  "_seq_no": 1000,
  "_type": "_doc",
  "_shards": {
    "total": 2,
    "failed": 0,
    "successful": 1
  },
  "_version": 2,
  "_id": "1",
  "_index": "bank",
  "_primary_term": 1
}