此 API 用于获取 Easysearch 集群中一个或多个指定搜索管道(Search Pipeline)的配置信息。
API #
GET /_search/pipeline/{id}
API 的作用 #
获取指定搜索管道的配置信息。可以查询单个管道或通过逗号分隔查询多个管道。返回的信息包括:
- 管道 ID:管道的唯一标识符
- 配置内容:管道的处理器配置(请求处理器和响应处理器)
- 版本信息:管道的当前版本号
API 的参数 #
路由参数 #
| 参数 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
id | string | 必需 | 管道的 ID 支持: - 单个 ID: my-pipeline- 多个 ID(逗号分隔): pipeline1,pipeline2,pipeline3 |
查询字符串参数 #
| 参数 | 类型 | 是否必需 | 默认值 | 描述 |
|---|---|---|---|---|
master_timeout | time | 可选 | 30s | 等待主节点响应的超时时间 如果主节点未发现或断开连接,等待指定时间后操作失败 |
local | boolean | 可选 | false | 是否从本地节点返回信息true:从本地节点获取false:从主节点获取 |
请求示例 #
# 查询单个管道
GET /_search/pipeline/my-pipeline
# 查询多个管道(逗号分隔)
GET /_search/pipeline/pipeline1,pipeline2,pipeline3
# 设置主节点超时时间
GET /_search/pipeline/my-pipeline?master_timeout=60s
# 从本地节点获取信息
GET /_search/pipeline/my-pipeline?local=true
响应示例 #
成功响应 - 单个管道 #
{
"count": 1,
"search_pipelines": {
"semantic-pipeline": {
"config": {
"request_processors": [
{
"type": "semantic_query_enricher",
"tag": "semantic_enrichment",
"description": "使用语义增强查询",
"model_name": "text-embedding-ada-002",
"api_key": "ENCRYPTED_VALUE:aBc123...infinilabs",
"text_field": "content",
"embedding_field": "content_embedding"
}
],
"response_processors": [
{
"type": "rerank",
"tag": "rerank_results",
"description": "重新排序搜索结果",
"rerank_model": "my-rerank-model",
"top_n": 10
}
]
},
"version": 2
}
}
}
成功响应 - 多个管道 #
{
"count": 2,
"search_pipelines": {
"filter-pipeline": {
"config": {
"request_processors": [
{
"type": "filter_query",
"tag": "public_filter",
"description": "只返回公开数据",
"query": {
"term": {
"visibility": "public"
}
},
"ignore_failure": true
}
]
},
"version": 1
},
"rename-pipeline": {
"config": {
"response_processors": [
{
"type": "rename_field",
"tag": "rename_fields",
"field_mappings": [
{
"old_field": "title",
"new_field": "headline"
},
{
"old_field": "body",
"new_field": "content"
}
]
}
]
},
"version": 1
}
}
}
响应字段说明 #
| 字段 | 类型 | 描述 |
|---|---|---|
count | integer | 返回的搜索管道数量 |
search_pipelines | object | 以管道 ID 为键的管道配置对象 |
search_pipelines.{id} | object | 特定管道的配置 |
search_pipelines.{id}.config | object | 管道配置对象 |
search_pipelines.{id}.config.request_processors | array | 请求处理器列表 |
search_pipelines.{id}.config.response_processors | array | 响应处理器列表 |
search_pipelines.{id}.version | integer | 管道版本号 |
错误响应 - 管道不存在 #
{
"error": {
"root_cause": [
{
"type": "resource_not_found_exception",
"reason": "search_pipeline [non-existent-pipeline] missing"
}
],
"type": "resource_not_found_exception",
"reason": "search_pipeline [non-existent-pipeline] missing"
},
"status": 404
}
请求处理器常见字段 #
| 字段 | 类型 | 描述 |
|---|---|---|
type | string | 处理器类型 |
tag | string | 处理器的标识符(可选) |
description | string | 处理器的描述信息(可选) |
ignore_failure | boolean | 处理器失败时是否忽略(可选) |
响应处理器常见字段 #
| 字段 | 类型 | 描述 |
|---|---|---|
type | string | 处理器类型 |
tag | string | 处理器的标识符(可选) |
description | string | 处理器的描述信息(可选) |
ignore_failure | boolean | 处理器失败时是否忽略(可选) |
使用场景 #
- 管道验证:在搜索前验证管道配置是否正确
- 配置查看:查看特定管道的详细配置
- 问题排查:诊断搜索管道相关的问题
- 版本对比:检查管道版本号以确定是否需要更新
与相关 API 的区别 #
| API | 功能 |
|---|---|
GET /_search/pipeline | 获取所有搜索管道 |
GET /_search/pipeline/{id} | 获取指定搜索管道 |
PUT /_search/pipeline/{id} | 创建或更新搜索管道 |
DELETE /_search/pipeline/{id} | 删除搜索管道 |
请求处理器类型 #
常见的请求处理器类型包括:
| 处理器 | 功能 |
|---|---|
filter_query | 添加查询过滤条件 |
script | 使用脚本修改搜索请求 |
semantic_query_enricher | 语义查询增强(AI 功能) |
响应处理器类型 #
常见的响应处理器类型包括:
| 处理器 | 功能 |
|---|---|
rename_field | 重命名字段 |
script | 使用脚本处理搜索结果 |
rerank | 结果重排序 |
注意事项 #
- 此 API 只支持 GET 方法
- API 密钥在返回时以加密格式显示(
ENCRYPTED_VALUE...infinilabs) local=true时可能返回过时信息,但响应更快- 支持通过逗号分隔查询多个管道
- 如果指定的管道不存在,返回 404 错误





