Test query ruleset
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Test query ruleset
editEvaluates 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
editPOST _query_rules/<ruleset_id>/_test
Prerequisites
editRequires 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.metadatafield of the rule.
Response codes
edit-
400 -
The
ruleset_idormatch_criteriawere not provided. -
404(Missing resources) -
No query ruleset matching
ruleset_idcould be found.
Examples
editTo 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"
}
]
}