List query rulesets
Returns information about all stored query rulesets. Summary information on the number of rules per ruleset will be returned, and full details can be returned with the Get query ruleset command.
Request
GET _query_rules/
Prerequisites
Requires the manage_search_query_rules privilege.
Path parameters
-
size - (Optional, integer) Maximum number of results to retrieve.
-
from - (Optional, integer) The offset from the first result to fetch.
Examples
The following example lists all configured query rulesets:
resp = client.query_rules.list_rulesets() print(resp)
const response = await client.transport.request({
method: "GET",
path: "/_query_rules",
});
console.log(response); GET _query_rules/
The following example lists the first three query rulesets:
resp = client.query_rules.list_rulesets(
from_="0",
size="3",
)
print(resp) const response = await client.transport.request({
method: "GET",
path: "/_query_rules",
querystring: {
from: "0",
size: "3",
},
});
console.log(response); GET _query_rules/?from=0&size=3
A sample response:
{
"count": 3,
"results": [
{
"ruleset_id": "ruleset-1",
"rule_total_count": 1,
"rule_criteria_types_counts": {
"exact": 1
},
"rule_type_counts": {
"pinned": 1
}
},
{
"ruleset_id": "ruleset-2",
"rule_total_count": 2,
"rule_criteria_types_counts": {
"exact": 1,
"fuzzy": 1
},
"rule_type_counts": {
"pinned": 2
}
},
{
"ruleset_id": "ruleset-3",
"rule_total_count": 3,
"rule_criteria_types_counts": {
"exact": 1,
"fuzzy": 2
},
"rule_type_counts": {
"pinned": 2,
"exclude": 1
}
}
]
} The counts in rule_criteria_types_counts may be larger than the value of rule_total_count, because a rule may have multiple criteria.
© 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/list-query-rulesets.html