模拟(Simulate)

class elasticsearch.client.SimulateClient

To use this client, access client.simulate from an Elasticsearch client. For example:

from elasticsearch import Elasticsearch

# Create the client instance
client = Elasticsearch(...)
# Use the simulate client
client.simulate.<method>(...)
ingest(*, docs=None, index=None, component_template_substitutions=None, error_trace=None, filter_path=None, human=None, index_template_substitutions=None, mapping_addition=None, pipeline=None, pipeline_substitutions=None, pretty=None, body=None)

模拟数据摄入过程。 对一组提供的文档运行摄入管道(可选择使用替代管道定义),以模拟将数据摄入到索引中的过程。

此API专用于故障排查或管道开发,因为它实际上不会将任何数据索引到Elasticsearch中。

API会针对请求体中提供的文档集运行该索引的默认和最终管道。 如果管道包含重定向处理器,它会跟随该处理器到新索引,并以与非模拟摄入相同的方式运行该索引的管道。 不会向Elasticsearch索引任何数据。 相反,API会返回转换后的文档,以及已运行的管道列表和若非模拟情况下文档将被索引到的索引名称。 转换后的文档会根据适用于该索引的映射进行验证,任何验证错误都会在结果中报告。

此API与模拟管道API的区别在于:后者需要指定单一管道且仅运行该管道。 模拟管道API更适合开发单个管道,而模拟摄入API更适合排查摄入到索引时多个管道交互的问题。

默认使用系统中当前的管道定义。 但您可以在请求体中提供替代管道定义。 这些将替代系统中已有的管道定义,可用于替换现有定义或创建新定义。管道替换仅在此请求内有效。

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-simulate-ingest

Parameters:
  • docs (Sequence[Mapping[str, Any]] | None) – 要在管道中测试的样本文档。

  • index (str | None) – 模拟摄入的目标索引。该值可通过在每个文档上指定索引来覆盖。 如果在请求路径中指定此参数,它将用于未显式指定索引参数的所有文档。

  • component_template_substitutions (Mapping[str, Mapping[str, Any]] | None) – 组件模板名称到替代组件模板定义对象的映射。

  • index_template_substitutions (Mapping[str, Mapping[str, Any]] | None) – 索引模板名称到替代索引模板定义对象的映射。

  • mapping_addition (Mapping[str, Any] | None)

  • pipeline (str | None) – 用作默认管道的管道。该值可用于覆盖索引的默认管道。

  • pipeline_substitutions (Mapping[str, Mapping[str, Any]] | None) – 要测试的管道。如果未指定`pipeline`请求路径参数,则此参数为必填项。 如果同时指定此参数和请求路径参数,API将仅使用请求路径参数。

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

  • body (Dict[str, Any] | None)

Return type:

ObjectApiResponse[Any]