存储与消息
Elasticsearch
type toElasticsearch
写入 Elasticsearch 索引
使用说明
要点:写入 Elasticsearch 索引,clusterName 对应 Camel Elasticsearch 集群名。
属性
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
clusterName集群名 |
文本 | 必填 | elasticsearch |
|
indexName索引名 |
文本 | 必填 | — | |
operation操作 |
枚举 | 可选 | INDEX |
示例流程
可直接保存为 demo-toElasticsearch.json 并部署;非入口节点默认套了一个 REST 入口。
{
"id": "demo-toElasticsearch",
"desc": "Elasticsearch 示例",
"group": "示例/存储与消息",
"schemaVersion": 1,
"nodes": [
{
"id": "n1",
"type": "rest",
"props": {
"method": "POST",
"path": "/demo/toElasticsearch",
"desc": "示例入口"
}
},
{
"type": "toElasticsearch",
"props": {
"clusterName": "elasticsearch",
"indexName": "demo-orders",
"operation": "INDEX"
},
"id": "n1"
}
]
}
curl -X POST 'http://localhost:8086/flow' \
-H 'Content-Type: application/json' \
-H 'X-Flow-Token: change-me' \
--data-binary @demo-toElasticsearch.json
调用方式
curl -X POST 'http://localhost:8086/demo/toElasticsearch' \
-H 'Content-Type: application/json' \
-d '{"id":1001,"amount":12800}'