You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python中Elasticsearch API的IngestClient正确导入方式

正确导入Elasticsearch IngestClient的方法

根据Elasticsearch Python客户端的最新规范,原from elasticsearch.client import IngestClient的导入方式已被弃用,正确的导入方式是直接从elasticsearch主模块导入:

from elasticsearch import IngestClient

使用示例

你可以像之前一样实例化IngestClient,只需将它关联到已创建的Elasticsearch客户端实例:

from elasticsearch import Elasticsearch, IngestClient

# 初始化主Elasticsearch客户端
es = Elasticsearch("http://localhost:9200")
# 初始化IngestClient
ingest_client = IngestClient(es)

# 调用Ingest API示例,比如创建pipeline
ingest_client.put_pipeline(
    id="my_pipeline",
    body={"description": "Test pipeline", "processors": []}
)

另外,也可以直接通过主Elasticsearch客户端的ingest属性访问Ingest相关API,无需单独实例化IngestClient:

es.ingest.put_pipeline(
    id="my_pipeline",
    body={"description": "Test pipeline", "processors": []}
)

内容的提问来源于stack exchange,提问作者Alex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 08:07:04