获取查询规则集

编辑

检索有关查询规则集的信息。

请求

编辑

GET _query_rules/<ruleset_id>

先决条件

编辑

需要 manage_search_query_rules 权限。

路径参数

编辑
<ruleset_id>
(必需,字符串)

响应代码

编辑
400
未提供 ruleset_id
404 (缺少资源)
未找到与 ruleset_id 匹配的查询规则集。

示例

编辑

以下示例获取名为 my-ruleset 的查询规则集

resp = client.query_rules.get_ruleset(
    ruleset_id="my-ruleset",
)
print(resp)
const response = await client.transport.request({
  method: "GET",
  path: "/_query_rules/my-ruleset",
});
console.log(response);
GET _query_rules/my-ruleset/

一个示例响应

{
    "ruleset_id": "my-ruleset",
    "rules": [
        {
            "rule_id": "my-rule1",
            "type": "pinned",
            "criteria": [
                {
                    "type": "contains",
                    "metadata": "query_string",
                    "values": [ "pugs", "puggles" ]
                }
            ],
            "actions": {
                "ids": [
                    "id1",
                    "id2"
                ]
            }
        },
        {
            "rule_id": "my-rule2",
            "type": "pinned",
            "criteria": [
                {
                    "type": "fuzzy",
                    "metadata": "query_string",
                    "values": [ "rescue dogs" ]
                }
            ],
            "actions": {
                "docs": [
                    {
                        "_index": "index1",
                        "_id": "id3"
                    },
                    {
                        "_index": "index2",
                        "_id": "id4"
                    }
                ]
            }
        }
    ]
}