- Elasticsearch 教程
- Elasticsearch - 主页
- Elasticsearch - 基本概念
- Elasticsearch - 安装
- Elasticsearch - 填充
- 版本之间的迁移
- Elasticsearch - API 约定
- Elasticsearch - 文档 API
- Elasticsearch - 搜索 API
- Elasticsearch - 聚合
- Elasticsearch - 索引 API
- Elasticsearch - CAT API
- Elasticsearch - 集群 API
- Elasticsearch - 查询 DSL
- Elasticsearch - 映射
- Elasticsearch - 分析
- Elasticsearch - 模块
- Elasticsearch - 索引模块
- Elasticsearch - 摄取节点
- Elasticsearch - 管理索引生命周期
- Elasticsearch - SQL 访问
- Elasticsearch - 监控
- Elasticsearch - 汇总数据
- Elasticsearch - 冻结索引
- Elasticsearch - 测试
- Elasticsearch - Kibana 仪表板
- Elasticsearch - 按字段过滤
- Elasticsearch - 数据表
- Elasticsearch - 区域地图
- Elasticsearch - 饼图
- Elasticsearch - 面积图和条形图
- Elasticsearch - 时间序列
- Elasticsearch - 标签云
- Elasticsearch - 热图
- Elasticsearch - 画布
- Elasticsearch - 日志 UI
- Elasticsearch 有用资源
- Elasticsearch - 快速指南
- Elasticsearch - 有用的资源
- Elasticsearch - 讨论
Elasticsearch - IngestNode
| 索引.块.read_only | 1 对/错 | 设置为 true 可使索引和索引元数据只读,设置为 false 允许写入和元数据更改。 |
有时我们需要在索引文档之前对其进行转换。例如,我们想要从文档中删除一个字段或重命名一个字段然后对其建立索引。这是由摄取节点处理的。
集群中的每个节点都具有摄取能力,但也可以自定义为仅由特定节点处理。
涉及的步骤
摄取节点的工作涉及两个步骤 -
- 创建管道
- 创建文档
创建管道
首先创建一个包含处理器的管道,然后执行该管道,如下所示 -
PUT _ingest/pipeline/int-converter
{
"description": "converts the content of the seq field to an integer",
"processors" : [
{
"convert" : {
"field" : "seq",
"type": "integer"
}
}
]
}
运行上面的代码,我们得到以下结果 -
{
"acknowledged" : true
}
创建文档
接下来我们使用管道转换器创建一个文档。
PUT /logs/_doc/1?pipeline=int-converter
{
"seq":"21",
"name":"Tutorialspoint",
"Addrs":"Hyderabad"
}
运行上面的代码,我们得到如下所示的响应 -
{
"_index" : "logs",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
接下来我们使用 GET 命令搜索上面创建的文档,如下所示 -
GET /logs/_doc/1
运行上面的代码,我们得到以下结果 -
{
"_index" : "logs",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"_seq_no" : 0,
"_primary_term" : 1,
"found" : true,
"_source" : {
"Addrs" : "Hyderabad",
"name" : "Tutorialspoint",
"seq" : 21
}
}
上面你可以看到21已经变成了一个整数。
无管道
现在我们在不使用管道的情况下创建一个文档。
PUT /logs/_doc/2
{
"seq":"11",
"name":"Tutorix",
"Addrs":"Secunderabad"
}
GET /logs/_doc/2
运行上面的代码,我们得到以下结果 -
{
"_index" : "logs",
"_type" : "_doc",
"_id" : "2",
"_version" : 1,
"_seq_no" : 1,
"_primary_term" : 1,
"found" : true,
"_source" : {
"seq" : "11",
"name" : "Tutorix",
"Addrs" : "Secunderabad"
}
}
您可以在上面看到 11 是一个没有使用管道的字符串。