apoc.es.getRaw
过程 Apoc 扩展
apoc.es.getRaw(host-or-key,path,payload-or-null,$config) yield value - 在 elastic search 上执行原始 GET 操作
签名
apoc.es.getRaw(host :: STRING?, path :: STRING?, payload :: ANY?, config = {} :: MAP?) :: (value :: MAP?)
用法示例
本节中的示例基于以下 Elastic 实例
version: '3.5'
services:
elastic:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
ports:
- 9200:9200
- 9300:9300
environment:
- discovery.type=single-node
该实例的数据集通过下载 此文件 并执行命令创建
curl -H 'Content-Type: application/json' -XPOST 'localhost:9200/bank/_bulk?pretty&refresh' --data-binary '@accounts.json'
我们可以通过运行以下查询来查找 ID 为 1 的文档
CALL apoc.es.getRaw("localhost","bank/_doc/1",null);
| 值 |
|---|
{_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} |
我们可以通过运行以下查询来查找地址为 mill lane 的文档
CALL apoc.es.getRaw("localhost","bank/_search",{
query: { match_phrase: { address: "mill lane" } }
});
| 值 |
|---|
{_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} |