apoc.es.getRaw
Procedure Apoc Extended
apoc.es.getRaw(host-or-key,path,payload-or-null,$config) yield value - perform a raw GET operation on elastic search
Signature
apoc.es.getRaw(host :: STRING?, path :: STRING?, payload :: ANY?, config = {} :: MAP?) :: (value :: MAP?)
Input parameters
Name | Type | Default |
---|---|---|
host |
STRING? |
null |
path |
STRING? |
null |
payload |
ANY? |
null |
config |
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 find the document with id 1
, by running the following query:
CALL apoc.es.getRaw("localhost","bank/_doc/1",null);
value |
---|
{_seq_no: 0, found: TRUE, _index: "bank", _type: "_doc", _source: {account_number: 1, firstname: "Amber", address: "880 Holmes Lane", balance: 39225, gender: "M", city: "Brogan", employer: "Pyrami", state: "IL", age: 32, email: "amberduke@pyrami.com", lastname: "Duke"}, _id: "1", _version: 1, _primary_term: 1} |
We can find the documents that have an address of mill lane
, by running the following query:
CALL apoc.es.getRaw("localhost","bank/_search",{
query: { match_phrase: { address: "mill lane" } }
});
value |
---|
{_shards: {total: 1, failed: 0, successful: 1, skipped: 0}, hits: {hits: [{_type: "_doc", _source: {account_number: 136, firstname: "Winnie", address: "198 Mill Lane", balance: 45801, gender: "M", city: "Urie", employer: "Neteria", state: "IL", age: 38, email: "winnieholland@neteria.com", lastname: "Holland"}, _id: "136", _index: "bank", _score: 9.507477}], total: {value: 1, relation: "eq"}, max_score: 9.507477}, took: 2, timed_out: FALSE} |