索引映射工具
2.13 版本引入
IndexMappingTool
用于检索集群中索引的映射和设置信息。
步骤 1:注册一个将运行 IndexMappingTool 的流代理
流代理按顺序运行一系列工具,并返回最后一个工具的输出。要创建流代理,请发送以下注册代理请求:
POST /_plugins/_ml/agents/_register
{
"name": "Test_Agent_For_IndexMapping_tool",
"type": "flow",
"description": "this is a test agent for the IndexMappingTool",
"tools": [
{
"type": "IndexMappingTool",
"name": "DemoIndexMappingTool",
"parameters": {
"index": "${parameters.index}",
"input": "${parameters.question}"
}
}
]
}
有关参数描述,请参阅注册参数。
OpenSearch 返回一个代理 ID
{
"agent_id": "9X7xWI0Bpc3sThaJdY9i"
}
步骤 2:运行代理
在运行该代理之前,请确保添加示例 OpenSearch Dashboards Sample eCommerce orders
数据集。要了解更多信息,请参阅添加示例数据。
然后,通过发送以下请求并提供索引名称和问题来运行该代理
POST /_plugins/_ml/agents/9X7xWI0Bpc3sThaJdY9i/_execute
{
"parameters": {
"index": [ "sample-ecommerce" ],
"question": "What fields are in the sample-ecommerce index?"
}
}
OpenSearch 返回指定索引的映射和设置
{
"inference_results": [
{
"output": [
{
"name": "response",
"result": """index: sample-ecommerce
mappings:
properties={items_purchased_failure={type=integer}, items_purchased_success={type=integer}, order_id={type=integer}, timestamp={type=date}, total_revenue_usd={type=integer}}
settings:
index.creation_date=1706752839713
index.number_of_replicas=1
index.number_of_shards=1
index.provided_name=sample-ecommerce
index.replication.type=DOCUMENT
index.uuid=UPYOQcAfRGqFAlSxcZlRjw
index.version.created=137217827
"""
}
]
}
]
}
注册参数
下表列出了注册代理时可用的所有工具参数。
参数 | 类型 | 必需/可选 | 描述 |
---|---|---|---|
输入 | 字符串 | 必需 | 用于返回索引信息的用户输入。 |
索引 | 数组 | 必需 | 一个逗号分隔的一个或多个索引列表,用于获取映射和设置信息。默认为空列表,表示所有索引。 |
本地 | 布尔型 | 可选 | 是否仅返回本地节点的信息而不是集群管理器节点的信息(默认为false )。 |
执行参数
下表列出了运行代理时可用的所有工具参数。
参数 | 类型 | 必需/可选 | 描述 |
---|---|---|---|
问题 | 字符串 | 必需 | 要发送到 LLM 的自然语言问题。 |
索引 | 数组 | 可选 | 一个逗号分隔的一个或多个索引列表,用于获取映射和设置信息。默认为空列表,表示所有索引。 |