apoc.es.put

Procedure APOC Full

apoc.es.put(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null) yield value - perform a PUT operation on elastic search

Signature

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

Input parameters

Name Type Default

host

STRING?

null

index

STRING?

null

type

STRING?

null

id

STRING?

null

query

ANY?

null

payload

MAP?

{}

Output parameters

Name Type

value

MAP?

Usage Examples

The examples in this section are based on an Elastic instance populated with the accounts.json sample dataset from the Getting Started with Elasticsearch guide. You can find instructions for setting this up at github.com/neo4j-examples/elastic-example.

We can create a document with a name property of John Doe and document id of 2, in the customers index, by running the following query:

CALL apoc.es.put("localhost","customers","_doc", "2", null, {
  name: "John Doe"
});
Table 1. Results
value

{result: "created", _shards: {total: 2, failed: 0, successful: 1}, _seq_no: 2, _index: "customers", _type: "_doc", _id: "2", _version: 1, _primary_term: 1}

We can update this document to add an address, by running the following query:

CALL apoc.es.put("localhost","customers","_doc", "2", null, {
  name: "John Doe",
  address: "Buckingham Palace"
});
Table 2. Results
value

{result: "updated", _shards: {total: 2, failed: 0, successful: 1}, _seq_no: 5, _index: "customers", _type: "_doc", _id: "2", _version: 2, _primary_term: 1}