apoc.es.post

This is the APOC Extended documentation.

APOC Extended is not supported by Neo4j. For the officially supported APOC Core, go to the APOC Core page.

Procedure Apoc Extended

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

Signature

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

Input parameters

Name Type Default

host

STRING?

null

index

STRING?

null

type

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 in the customers index, by running the following query:

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

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

Elastic will generate an _id value for us when we use apoc.es.post. If we want to provide an id, or update an existing document, see apoc.es.put.