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

Test query ruleset

New API reference

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

Evaluates match criteria against a query ruleset to identify the rules that would match that criteria.

This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.

Request

POST _query_rules/<ruleset_id>/_test

Prerequisites

Requires the manage_search_query_rules privilege.

Path parameters

<ruleset_id>
(Required, string)

Request body

match_criteria
(Required, object) Defines the match criteria to apply to rules in the given query ruleset. Match criteria should match the keys defined in the criteria.metadata field of the rule.

Response codes

400
The ruleset_id or match_criteria were not provided.
404 (Missing resources)
No query ruleset matching ruleset_id could be found.

Examples

To test a ruleset, provide the match criteria that you want to test against:

resp = client.query_rules.test(
    ruleset_id="my-ruleset",
    match_criteria={
        "query_string": "puggles"
    },
)
print(resp)
const response = await client.transport.request({
  method: "POST",
  path: "/_query_rules/my-ruleset/_test",
  body: {
    match_criteria: {
      query_string: "puggles",
    },
  },
});
console.log(response);
POST _query_rules/my-ruleset/_test
{
    "match_criteria": {
        "query_string": "puggles"
    }
}

A sample response:

{
    "total_matched_rules": 1,
    "matched_rules": [
        {
            "ruleset_id": "my-ruleset",
            "rule_id": "my-rule1"
        }
    ]
}

© 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/test-query-ruleset.html

Spec-Zone.ru

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