- Elasticsearch 指南其他版本
- 8.17 中的新功能
- Elasticsearch 基础
- 快速入门
- 设置 Elasticsearch
- 升级 Elasticsearch
- 索引模块
- 映射
- 文本分析
- 索引模板
- 数据流
- 摄取管道
- 别名
- 搜索您的数据
- 重新排名
- 查询 DSL
- 聚合
- 地理空间分析
- 连接器
- EQL
- ES|QL
- SQL
- 脚本
- 数据管理
- 自动缩放
- 监视集群
- 汇总或转换数据
- 设置高可用性集群
- 快照和还原
- 保护 Elastic Stack 的安全
- Watcher
- 命令行工具
- elasticsearch-certgen
- elasticsearch-certutil
- elasticsearch-create-enrollment-token
- elasticsearch-croneval
- elasticsearch-keystore
- elasticsearch-node
- elasticsearch-reconfigure-node
- elasticsearch-reset-password
- elasticsearch-saml-metadata
- elasticsearch-service-tokens
- elasticsearch-setup-passwords
- elasticsearch-shard
- elasticsearch-syskeygen
- elasticsearch-users
- 优化
- 故障排除
- 修复常见的集群问题
- 诊断未分配的分片
- 向系统中添加丢失的层
- 允许 Elasticsearch 在系统中分配数据
- 允许 Elasticsearch 分配索引
- 索引将索引分配过滤器与数据层节点角色混合,以在数据层之间移动
- 没有足够的节点来分配所有分片副本
- 单个节点上索引的分片总数已超过
- 每个节点的分片总数已达到
- 故障排除损坏
- 修复磁盘空间不足的数据节点
- 修复磁盘空间不足的主节点
- 修复磁盘空间不足的其他角色节点
- 启动索引生命周期管理
- 启动快照生命周期管理
- 从快照恢复
- 故障排除损坏的存储库
- 解决重复的快照策略失败问题
- 故障排除不稳定的集群
- 故障排除发现
- 故障排除监控
- 故障排除转换
- 故障排除 Watcher
- 故障排除搜索
- 故障排除分片容量健康问题
- 故障排除不平衡的集群
- 捕获诊断信息
- REST API
- API 约定
- 通用选项
- REST API 兼容性
- 自动缩放 API
- 行为分析 API
- 紧凑和对齐文本 (CAT) API
- 集群 API
- 跨集群复制 API
- 连接器 API
- 数据流 API
- 文档 API
- 丰富 API
- EQL API
- ES|QL API
- 功能 API
- Fleet API
- 图表探索 API
- 索引 API
- 别名是否存在
- 别名
- 分析
- 分析索引磁盘使用量
- 清除缓存
- 克隆索引
- 关闭索引
- 创建索引
- 创建或更新别名
- 创建或更新组件模板
- 创建或更新索引模板
- 创建或更新索引模板(旧版)
- 删除组件模板
- 删除悬挂索引
- 删除别名
- 删除索引
- 删除索引模板
- 删除索引模板(旧版)
- 存在
- 字段使用情况统计信息
- 刷新
- 强制合并
- 获取别名
- 获取组件模板
- 获取字段映射
- 获取索引
- 获取索引设置
- 获取索引模板
- 获取索引模板(旧版)
- 获取映射
- 导入悬挂索引
- 索引恢复
- 索引段
- 索引分片存储
- 索引统计信息
- 索引模板是否存在(旧版)
- 列出悬挂索引
- 打开索引
- 刷新
- 解析索引
- 解析集群
- 翻转
- 收缩索引
- 模拟索引
- 模拟模板
- 拆分索引
- 解冻索引
- 更新索引设置
- 更新映射
- 索引生命周期管理 API
- 推理 API
- 信息 API
- 摄取 API
- 许可 API
- Logstash API
- 机器学习 API
- 机器学习异常检测 API
- 机器学习数据帧分析 API
- 机器学习训练模型 API
- 迁移 API
- 节点生命周期 API
- 查询规则 API
- 重新加载搜索分析器 API
- 存储库计量 API
- 汇总 API
- 根 API
- 脚本 API
- 搜索 API
- 搜索应用程序 API
- 可搜索快照 API
- 安全 API
- 身份验证
- 更改密码
- 清除缓存
- 清除角色缓存
- 清除权限缓存
- 清除 API 密钥缓存
- 清除服务帐户令牌缓存
- 创建 API 密钥
- 创建或更新应用程序权限
- 创建或更新角色映射
- 创建或更新角色
- 批量创建或更新角色 API
- 批量删除角色 API
- 创建或更新用户
- 创建服务帐户令牌
- 委托 PKI 身份验证
- 删除应用程序权限
- 删除角色映射
- 删除角色
- 删除服务帐户令牌
- 删除用户
- 禁用用户
- 启用用户
- 注册 Kibana
- 注册节点
- 获取 API 密钥信息
- 获取应用程序权限
- 获取内置权限
- 获取角色映射
- 获取角色
- 查询角色
- 获取服务帐户
- 获取服务帐户凭据
- 获取安全设置
- 获取令牌
- 获取用户权限
- 获取用户
- 授予 API 密钥
- 具有权限
- 使 API 密钥失效
- 使令牌失效
- OpenID Connect 准备身份验证
- OpenID Connect 身份验证
- OpenID Connect 注销
- 查询 API 密钥信息
- 查询用户
- 更新 API 密钥
- 更新安全设置
- 批量更新 API 密钥
- SAML 准备身份验证
- SAML 身份验证
- SAML 注销
- SAML 失效
- SAML 完成注销
- SAML 服务提供商元数据
- SSL 证书
- 激活用户配置文件
- 禁用用户配置文件
- 启用用户配置文件
- 获取用户配置文件
- 建议用户配置文件
- 更新用户配置文件数据
- 具有用户配置文件权限
- 创建跨集群 API 密钥
- 更新跨集群 API 密钥
- 快照和还原 API
- 快照生命周期管理 API
- SQL API
- 同义词 API
- 文本结构 API
- 转换 API
- 使用情况 API
- Watcher API
- 定义
- 迁移指南
- 发行说明
- Elasticsearch 版本 8.17.0
- Elasticsearch 版本 8.16.1
- Elasticsearch 版本 8.16.0
- Elasticsearch 版本 8.15.5
- Elasticsearch 版本 8.15.4
- Elasticsearch 版本 8.15.3
- Elasticsearch 版本 8.15.2
- Elasticsearch 版本 8.15.1
- Elasticsearch 版本 8.15.0
- Elasticsearch 版本 8.14.3
- Elasticsearch 版本 8.14.2
- Elasticsearch 版本 8.14.1
- Elasticsearch 版本 8.14.0
- Elasticsearch 版本 8.13.4
- Elasticsearch 版本 8.13.3
- Elasticsearch 版本 8.13.2
- Elasticsearch 版本 8.13.1
- Elasticsearch 版本 8.13.0
- Elasticsearch 版本 8.12.2
- Elasticsearch 版本 8.12.1
- Elasticsearch 版本 8.12.0
- Elasticsearch 版本 8.11.4
- Elasticsearch 版本 8.11.3
- Elasticsearch 版本 8.11.2
- Elasticsearch 版本 8.11.1
- Elasticsearch 版本 8.11.0
- Elasticsearch 版本 8.10.4
- Elasticsearch 版本 8.10.3
- Elasticsearch 版本 8.10.2
- Elasticsearch 版本 8.10.1
- Elasticsearch 版本 8.10.0
- Elasticsearch 版本 8.9.2
- Elasticsearch 版本 8.9.1
- Elasticsearch 版本 8.9.0
- Elasticsearch 版本 8.8.2
- Elasticsearch 版本 8.8.1
- Elasticsearch 版本 8.8.0
- Elasticsearch 版本 8.7.1
- Elasticsearch 版本 8.7.0
- Elasticsearch 版本 8.6.2
- Elasticsearch 版本 8.6.1
- Elasticsearch 版本 8.6.0
- Elasticsearch 版本 8.5.3
- Elasticsearch 版本 8.5.2
- Elasticsearch 版本 8.5.1
- Elasticsearch 版本 8.5.0
- Elasticsearch 版本 8.4.3
- Elasticsearch 版本 8.4.2
- Elasticsearch 版本 8.4.1
- Elasticsearch 版本 8.4.0
- Elasticsearch 版本 8.3.3
- Elasticsearch 版本 8.3.2
- Elasticsearch 版本 8.3.1
- Elasticsearch 版本 8.3.0
- Elasticsearch 版本 8.2.3
- Elasticsearch 版本 8.2.2
- Elasticsearch 版本 8.2.1
- Elasticsearch 版本 8.2.0
- Elasticsearch 版本 8.1.3
- Elasticsearch 版本 8.1.2
- Elasticsearch 版本 8.1.1
- Elasticsearch 版本 8.1.0
- Elasticsearch 版本 8.0.1
- Elasticsearch 版本 8.0.0
- Elasticsearch 版本 8.0.0-rc2
- Elasticsearch 版本 8.0.0-rc1
- Elasticsearch 版本 8.0.0-beta1
- Elasticsearch 版本 8.0.0-alpha2
- Elasticsearch 版本 8.0.0-alpha1
- 依赖项和版本
模拟摄取 API
编辑模拟摄取 API
编辑针对一组提供的文档执行摄取管道,可以选择使用替换的管道定义。此 API 旨在用于故障排除或管道开发,因为它实际上不会将任何数据索引到 Elasticsearch 中。
resp = client.simulate.ingest( body={ "docs": [ { "_index": "my-index", "_id": "id", "_source": { "foo": "bar" } }, { "_index": "my-index", "_id": "id", "_source": { "foo": "rab" } } ], "pipeline_substitutions": { "my-pipeline": { "processors": [ { "set": { "field": "field3", "value": "value3" } } ] } }, "component_template_substitutions": { "my-component-template": { "template": { "mappings": { "dynamic": "true", "properties": { "field3": { "type": "keyword" } } }, "settings": { "index": { "default_pipeline": "my-pipeline" } } } } }, "index_template_substitutions": { "my-index-template": { "index_patterns": [ "my-index-*" ], "composed_of": [ "component_template_1", "component_template_2" ] } }, "mapping_addition": { "dynamic": "strict", "properties": { "foo": { "type": "keyword" } } } }, ) print(resp)
const response = await client.simulate.ingest({ body: { docs: [ { _index: "my-index", _id: "id", _source: { foo: "bar", }, }, { _index: "my-index", _id: "id", _source: { foo: "rab", }, }, ], pipeline_substitutions: { "my-pipeline": { processors: [ { set: { field: "field3", value: "value3", }, }, ], }, }, component_template_substitutions: { "my-component-template": { template: { mappings: { dynamic: "true", properties: { field3: { type: "keyword", }, }, }, settings: { index: { default_pipeline: "my-pipeline", }, }, }, }, }, index_template_substitutions: { "my-index-template": { index_patterns: ["my-index-*"], composed_of: ["component_template_1", "component_template_2"], }, }, mapping_addition: { dynamic: "strict", properties: { foo: { type: "keyword", }, }, }, }, }); console.log(response);
POST /_ingest/_simulate { "docs": [ { "_index": "my-index", "_id": "id", "_source": { "foo": "bar" } }, { "_index": "my-index", "_id": "id", "_source": { "foo": "rab" } } ], "pipeline_substitutions": { "my-pipeline": { "processors": [ { "set": { "field": "field3", "value": "value3" } } ] } }, "component_template_substitutions": { "my-component-template": { "template": { "mappings": { "dynamic": "true", "properties": { "field3": { "type": "keyword" } } }, "settings": { "index": { "default_pipeline": "my-pipeline" } } } } }, "index_template_substitutions": { "my-index-template": { "index_patterns": ["my-index-*"], "composed_of": ["component_template_1", "component_template_2"] } }, "mapping_addition": { "dynamic": "strict", "properties": { "foo": { "type": "keyword" } } } }
这会在本次请求期间将现有的 |
|
这会在本次请求期间将现有的 |
|
这会在本次请求期间将现有的 |
|
此映射会在验证之前合并到索引的最终映射中。它仅在本次请求期间使用。 |
请求
编辑POST /_ingest/_simulate
GET /_ingest/_simulate
POST /_ingest/<target>/_simulate
GET /_ingest/<target>/_simulate
描述
编辑模拟摄取 API 模拟将数据摄取到索引中。它针对请求正文中提供的一组文档执行该索引的默认和最终管道。如果管道包含 重路由处理器,它将遵循该重路由处理器到新索引,并以非模拟摄取相同的方式执行该索引的管道。没有任何数据索引到 Elasticsearch 中。相反,将返回转换后的文档,以及已执行的管道列表和文档在非模拟情况下将被索引到的索引的名称。转换后的文档将根据适用于此索引的映射进行验证,并且任何验证错误都将在结果中报告。
此 API 与 模拟管道 API 的不同之处在于,您在该 API 中指定单个管道,并且它只运行该一个管道。模拟管道 API 更适用于开发单个管道,而模拟摄取 API 更适用于对摄取到索引时应用的各种管道的交互进行故障排除。
默认情况下,使用当前系统中存在的管道定义。但是,您可以在请求正文中提供替换的管道定义。这些定义将用于代替系统中已有的管道定义。这可以用于替换现有管道定义或创建新管道定义。管道替换仅在此请求中使用。
路径参数
编辑-
<target>
- (可选,字符串) 要模拟摄取到的索引。可以通过在每个文档上指定索引来覆盖此值。如果在请求路径中提供 <target>,则它将用于任何未明确指定索引参数的文档。
查询参数
编辑-
pipeline
- (可选,字符串) 要用作默认管道的管道。这可以用于覆盖要摄取到的索引的默认管道。
请求正文
编辑-
docs
-
(必需,对象数组) 要在管道中测试的示例文档。
docs
对象的属性-
_id
- (可选,字符串) 文档的唯一标识符。
-
_index
- (可选,字符串) 文档将摄取到的索引的名称。
-
_source
- (必需,对象) 文档的 JSON 正文。
-
-
pipeline_substitutions
-
(可选,字符串到对象的映射) 管道 ID 到替换管道定义对象的映射。
管道定义对象的属性
-
description
- (可选,字符串) 摄取管道的描述。
-
on_failure
-
(可选,处理器 对象数组) 在处理器失败后立即运行的处理器。
每个处理器都支持处理器级别的
on_failure
值。如果一个没有on_failure
值的处理器失败,Elasticsearch 将使用此管道级别的参数作为回退。此参数中的处理器将按指定的顺序依次运行。Elasticsearch 将不会尝试运行管道的剩余处理器。 -
processors
- (必需,处理器 对象数组) 用于在索引之前对文档执行转换的处理器。处理器将按指定的顺序依次运行。
-
version
-
(可选,整数) 外部系统用于跟踪摄取管道的版本号。
有关如何使用 version 属性,请参阅上面的
if_version
参数。 -
_meta
- (可选,对象) 关于摄取管道的可选元数据。可以包含任何内容。此映射不是由 Elasticsearch 自动生成的。
-
deprecated
- (可选,布尔值) 将此摄取管道标记为已弃用。当在创建或更新非已弃用的索引模板时,引用已弃用的摄取管道作为默认或最终管道时,Elasticsearch 将发出弃用警告。
-
-
component_template_substitutions
-
(可选,字符串到对象的映射) 组件模板名称到替换组件模板定义对象的映射。
组件模板定义对象的属性
-
template
-
(必需,对象) 这是要应用的模板,可以选择包含
mappings
、settings
或aliases
配置。template
的属性-
aliases
-
(可选,对象数组) 要添加的别名。
如果索引模板包含
data_stream
对象,则这些是数据流别名。否则,这些是索引别名。数据流别名会忽略index_routing
、routing
和search_routing
选项。aliases
对象的属性-
<alias>
-
(必需,对象) 键是别名名称。索引别名名称支持日期数学。
对象正文包含别名的选项。支持空对象。
<alias>
的属性-
filter
- (可选,查询 DSL 对象) 用于限制别名可以访问的文档的查询。
-
index_routing
- (可选,字符串) 用于将索引操作路由到特定分片的值。如果指定,则会覆盖索引操作的
routing
值。 -
is_hidden
- (可选,布尔值) 如果为
true
,则别名是隐藏的。默认为false
。别名的所有索引都必须具有相同的is_hidden
值。 -
is_write_index
- (可选,布尔值) 如果为
true
,则索引是别名的写入索引。默认为false
。 -
routing
- (可选,字符串) 用于将索引和搜索操作路由到特定分片的值。
-
search_routing
- (可选,字符串) 用于将搜索操作路由到特定分片的值。如果指定,则会覆盖搜索操作的
routing
值。
-
-
-
mappings
-
(可选,映射对象) 索引中字段的映射。如果指定,则此映射可以包含
请参阅映射。
-
settings
- (可选,索引设置对象) 索引的配置选项。请参阅索引设置。
-
-
version
- (可选,整数) 用于在外部管理组件模板的版本号。此数字不是由 Elasticsearch 自动生成或递增的。
-
allow_auto_create
- (可选,布尔值) 此设置会覆盖
action.auto_create_index
集群设置的值。如果在模板中设置为true
,则即使通过actions.auto_create_index
禁用索引的自动创建,也可以使用该模板自动创建索引。如果设置为false
,则必须始终显式创建与模板匹配的索引或数据流,并且永远不能自动创建。 -
_meta
- (可选,对象) 关于组件模板的可选用户元数据。可以包含任何内容。此映射不是由 Elasticsearch 自动生成的。
-
deprecated
- (可选,布尔值) 将此组件模板标记为已弃用。当在创建或更新非已弃用的索引模板时引用已弃用的组件模板时,Elasticsearch 将发出弃用警告。
-
-
index_template_substitutions
-
(可选,字符串到对象的映射)索引模板名称到替换的索引模板定义对象的映射。
索引模板定义对象的属性
-
composed_of
- (可选,字符串数组)组件模板名称的有序列表。组件模板按照指定的顺序合并,这意味着最后指定的组件模板具有最高的优先级。有关示例,请参阅组合多个组件模板。
-
data_stream
-
(可选,对象)如果包含此对象,则该模板用于创建数据流及其后备索引。支持空对象。
数据流需要具有
data_stream
对象的匹配索引模板。请参阅创建索引模板。 -
index_patterns
-
(必需,字符串数组)用于在创建期间匹配数据流和索引名称的通配符 (
*
) 表达式数组。Elasticsearch 包括多个内置索引模板。为避免与这些模板发生名称冲突,请参阅避免索引模式冲突。
-
_meta
- (可选,对象)有关索引模板的可选用户元数据。可以包含任何内容。此映射不是由 Elasticsearch 自动生成的。
-
priority
- (可选,整数)在创建新数据流或索引时确定索引模板优先级的优先级。选择优先级最高的索引模板。如果未指定优先级,则将模板视为优先级为 0(最低优先级)。此数字不是由 Elasticsearch 自动生成的。
-
template
-
(可选,对象)要应用的模板。它可能可选地包含
aliases
、mappings
或settings
配置。template
的属性-
aliases
-
(可选,对象数组) 要添加的别名。
如果索引模板包含
data_stream
对象,则这些是数据流别名。否则,这些是索引别名。数据流别名会忽略index_routing
、routing
和search_routing
选项。aliases
对象的属性-
<alias>
-
(必需,对象) 键是别名名称。索引别名名称支持日期数学。
对象正文包含别名的选项。支持空对象。
<alias>
的属性-
filter
- (可选,查询 DSL 对象) 用于限制别名可以访问的文档的查询。
-
index_routing
- (可选,字符串) 用于将索引操作路由到特定分片的值。如果指定,则会覆盖索引操作的
routing
值。 -
is_hidden
- (可选,布尔值) 如果为
true
,则别名是隐藏的。默认为false
。别名的所有索引都必须具有相同的is_hidden
值。 -
is_write_index
- (可选,布尔值) 如果为
true
,则索引是别名的写入索引。默认为false
。 -
routing
- (可选,字符串) 用于将索引和搜索操作路由到特定分片的值。
-
search_routing
- (可选,字符串) 用于将搜索操作路由到特定分片的值。如果指定,则会覆盖搜索操作的
routing
值。
-
-
-
mappings
-
(可选,映射对象) 索引中字段的映射。如果指定,则此映射可以包含
请参阅映射。
-
settings
- (可选,索引设置对象) 索引的配置选项。请参阅索引设置。
-
-
version
- (可选,整数)用于在外部管理索引模板的版本号。此数字不是由 Elasticsearch 自动生成的。
-
deprecated
- (可选,布尔值)将此索引模板标记为已弃用。当创建或更新使用已弃用组件的非弃用索引模板时,Elasticsearch 将发出弃用警告。
-
-
mapping_addition
- (可选,映射对象)将合并到索引映射中的映射定义,以便在此请求过程中进行验证。
示例
编辑使用预先存在的管道定义
编辑在此示例中,索引 index
具有名为 my-pipeline
的默认管道和名为 my-final-pipeline
的最终管道。由于两个文档都正在摄取到 index
中,因此两个管道都将使用系统中已有的管道定义执行。
resp = client.simulate.ingest( body={ "docs": [ { "_index": "my-index", "_id": "123", "_source": { "foo": "bar" } }, { "_index": "my-index", "_id": "456", "_source": { "foo": "rab" } } ] }, ) print(resp)
response = client.simulate.ingest( body: { docs: [ { _index: 'my-index', _id: '123', _source: { foo: 'bar' } }, { _index: 'my-index', _id: '456', _source: { foo: 'rab' } } ] } ) puts response
const response = await client.simulate.ingest({ body: { docs: [ { _index: "my-index", _id: "123", _source: { foo: "bar", }, }, { _index: "my-index", _id: "456", _source: { foo: "rab", }, }, ], }, }); console.log(response);
POST /_ingest/_simulate { "docs": [ { "_index": "my-index", "_id": "123", "_source": { "foo": "bar" } }, { "_index": "my-index", "_id": "456", "_source": { "foo": "rab" } } ] }
API 返回以下响应
{ "docs": [ { "doc": { "_id": "123", "_index": "my-index", "_version": -3, "_source": { "field1": "value1", "field2": "value2", "foo": "bar" }, "executed_pipelines": [ "my-pipeline", "my-final-pipeline" ] } }, { "doc": { "_id": "456", "_index": "my-index", "_version": -3, "_source": { "field1": "value1", "field2": "value2", "foo": "rab" }, "executed_pipelines": [ "my-pipeline", "my-final-pipeline" ] } } ] }
在请求正文中指定管道替换
编辑在此示例中,索引 my-index
具有名为 my-pipeline
的默认管道和名为 my-final-pipeline
的最终管道。但在 pipeline_substitutions
中提供了 my-pipeline
的替代定义。将使用替代的 my-pipeline
代替系统中的 my-pipeline
,然后执行系统中已定义的 my-final-pipeline
。
resp = client.simulate.ingest( body={ "docs": [ { "_index": "my-index", "_id": "123", "_source": { "foo": "bar" } }, { "_index": "my-index", "_id": "456", "_source": { "foo": "rab" } } ], "pipeline_substitutions": { "my-pipeline": { "processors": [ { "uppercase": { "field": "foo" } } ] } } }, ) print(resp)
response = client.simulate.ingest( body: { docs: [ { _index: 'my-index', _id: '123', _source: { foo: 'bar' } }, { _index: 'my-index', _id: '456', _source: { foo: 'rab' } } ], pipeline_substitutions: { "my-pipeline": { processors: [ { uppercase: { field: 'foo' } } ] } } } ) puts response
const response = await client.simulate.ingest({ body: { docs: [ { _index: "my-index", _id: "123", _source: { foo: "bar", }, }, { _index: "my-index", _id: "456", _source: { foo: "rab", }, }, ], pipeline_substitutions: { "my-pipeline": { processors: [ { uppercase: { field: "foo", }, }, ], }, }, }, }); console.log(response);
POST /_ingest/_simulate { "docs": [ { "_index": "my-index", "_id": "123", "_source": { "foo": "bar" } }, { "_index": "my-index", "_id": "456", "_source": { "foo": "rab" } } ], "pipeline_substitutions": { "my-pipeline": { "processors": [ { "uppercase": { "field": "foo" } } ] } } }
API 返回以下响应
{ "docs": [ { "doc": { "_id": "123", "_index": "my-index", "_version": -3, "_source": { "field2": "value2", "foo": "BAR" }, "executed_pipelines": [ "my-pipeline", "my-final-pipeline" ] } }, { "doc": { "_id": "456", "_index": "my-index", "_version": -3, "_source": { "field2": "value2", "foo": "RAB" }, "executed_pipelines": [ "my-pipeline", "my-final-pipeline" ] } } ] }
在请求正文中指定组件模板替换
编辑在此示例中,假设索引 my-index
具有一个严格的映射,其中仅定义了 foo
关键字字段。假设该字段映射来自名为 my-mappings-template
的组件模板。我们想测试添加一个新字段 bar
。因此,在 component_template_substitutions
中提供了 my-mappings-template
的替代定义。将使用替代的 my-mappings-template
代替 my-index
的现有映射,并代替系统中的 my-mappings-template
。
resp = client.simulate.ingest( body={ "docs": [ { "_index": "my-index", "_id": "123", "_source": { "foo": "foo" } }, { "_index": "my-index", "_id": "456", "_source": { "bar": "rab" } } ], "component_template_substitutions": { "my-mappings_template": { "template": { "mappings": { "dynamic": "strict", "properties": { "foo": { "type": "keyword" }, "bar": { "type": "keyword" } } } } } } }, ) print(resp)
const response = await client.simulate.ingest({ body: { docs: [ { _index: "my-index", _id: "123", _source: { foo: "foo", }, }, { _index: "my-index", _id: "456", _source: { bar: "rab", }, }, ], component_template_substitutions: { "my-mappings_template": { template: { mappings: { dynamic: "strict", properties: { foo: { type: "keyword", }, bar: { type: "keyword", }, }, }, }, }, }, }, }); console.log(response);
POST /_ingest/_simulate { "docs": [ { "_index": "my-index", "_id": "123", "_source": { "foo": "foo" } }, { "_index": "my-index", "_id": "456", "_source": { "bar": "rab" } } ], "component_template_substitutions": { "my-mappings_template": { "template": { "mappings": { "dynamic": "strict", "properties": { "foo": { "type": "keyword" }, "bar": { "type": "keyword" } } } } } } }
API 返回以下响应
{ "docs": [ { "doc": { "_id": "123", "_index": "my-index", "_version": -3, "_source": { "foo": "foo" }, "executed_pipelines": [] } }, { "doc": { "_id": "456", "_index": "my-index", "_version": -3, "_source": { "bar": "rab" }, "executed_pipelines": [] } } ] }