Test query ruleset

edit

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

edit

POST _query_rules/<ruleset_id>/_test

Prerequisites

edit

Requires the manage_search_query_rules privilege.

Path parameters

edit
<ruleset_id>
(Required, string)

Request body

edit
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

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

Examples

edit

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)
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"
        }
    ]
}