Spec-Zone.ru › Elasticsearch 8
›Elasticsearch Guide [8.17] ›REST APIs ›Query rules APIs

Get query rule

New API reference

For the most up-to-date API details, refer to Query rules APIs.

Retrieves information about an individual query rule within a query ruleset.

Request

GET _query_rules/<ruleset_id>/_rule/<rule_id>

Prerequisites

Requires the manage_search_query_rules privilege.

Path parameters

<ruleset_id>
(Required, string)
<rule_id>
(Required, string)

Response codes

400
Missing ruleset_id or rule_id, or both.
404 (Missing resources)
Either no query ruleset matching ruleset_id could be found, or no rule matching rule_id could be found within that ruleset.

Examples

The following example gets the query rule with ID my-rule1 from the ruleset named my-ruleset:

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

A sample response:

{
    "rule_id": "my-rule1",
    "type": "pinned",
    "criteria": [
        {
            "type": "contains",
            "metadata": "query_string",
            "values": [ "pugs", "puggles" ]
        }
    ],
    "actions": {
        "ids": [
            "id1",
            "id2"
        ]
    }
}

© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/get-query-rule.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API