List query rulesets

List query rulesets

New API reference

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

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:

  1. resp = client.query_rules.list_rulesets()
  2. print(resp)
  1. const response = await client.transport.request({
  2. method: "GET",
  3. path: "/_query_rules",
  4. });
  5. console.log(response);
  1. GET _query_rules/

The following example lists the first three query rulesets:

  1. resp = client.query_rules.list_rulesets(
  2. from_="0",
  3. size="3",
  4. )
  5. print(resp)
  1. const response = await client.transport.request({
  2. method: "GET",
  3. path: "/_query_rules",
  4. querystring: {
  5. from: "0",
  6. size: "3",
  7. },
  8. });
  9. console.log(response);
  1. GET _query_rules/?from=0&size=3

A sample response:

  1. {
  2. "count": 3,
  3. "results": [
  4. {
  5. "ruleset_id": "ruleset-1",
  6. "rule_total_count": 1,
  7. "rule_criteria_types_counts": {
  8. "exact": 1
  9. },
  10. "rule_type_counts": {
  11. "pinned": 1
  12. }
  13. },
  14. {
  15. "ruleset_id": "ruleset-2",
  16. "rule_total_count": 2,
  17. "rule_criteria_types_counts": {
  18. "exact": 1,
  19. "fuzzy": 1
  20. },
  21. "rule_type_counts": {
  22. "pinned": 2
  23. }
  24. },
  25. {
  26. "ruleset_id": "ruleset-3",
  27. "rule_total_count": 3,
  28. "rule_criteria_types_counts": {
  29. "exact": 1,
  30. "fuzzy": 2
  31. },
  32. "rule_type_counts": {
  33. "pinned": 2,
  34. "exclude": 1
  35. }
  36. }
  37. ]
  38. }

The counts in rule_criteria_types_counts may be larger than the value of rule_total_count, because a rule may have multiple criteria.