---
type: api
title: Get all query rulesets
description: Get summarized information about the query rulesets.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-query-rules-list-rulesets
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-query-rules-list-rulesets
products:
  - Elasticsearch
---

# Get all query rulesets

Availability: Generally available since 8.10

## Paths

- `GET` `/_query_rules`

## Description

Get summarized information about the query rulesets.

## Required authorization

- Cluster privileges: `manage_search_query_rules`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/guide/en/elasticsearch/reference/current/token-authentication-services.html)

## Query string parameters

- `from` (number · default: 0) — optional
  The offset from the first result to fetch.
- `size` (number · default: 100) — optional
  The maximum number of results to retrieve.

## Response

`application/json`

- `count` (number)
- `results` (object[])
  - `ruleset_id` (string)
    A unique identifier for the ruleset.
  - `rule_total_count` (number)
    The number of rules associated with the ruleset.
  - `rule_criteria_types_counts` (map string to number)
    A map of criteria type (for example, `exact`) to the number of rules of that type.

NOTE: The counts in `rule_criteria_types_counts` may be larger than the value of `rule_total_count` because a rule may have multiple criteria.
  - `rule_type_counts` (map string to number)
    A map of rule type (for example, `pinned`) to the number of rules of that type.
## Code examples

#### Console

```console
GET _query_rules/?from=0&size=3
```

#### JavaScript

```javascript
const response = await client.queryRules.listRulesets({
  from: 0,
  size: 3,
});
```

#### Python

```python
resp = client.query_rules.list_rulesets(
    from_="0",
    size="3",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_query_rules/?from=0&size=3" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.queryRules().listRulesets(l -> l
    .from(0)
    .size(3)
);
```

#### C#

```c#
var response = await client.QueryRules
    .ListRulesetsAsync(d1 => d1
        .From(0)
        .Size(3)
    );
```

#### PHP

```php
$resp = $client->queryRules()->listRulesets([
    "from" => "0",
    "size" => "3",
]);
```

#### Ruby

```ruby
response = client.query_rules.list_rulesets(
  from: "0",
  size: "3"
)
```

## Response examples

#### Query ruleset list response example1

A successful response from `GET _query_rules/?from=0&size=3`.

```json
{
    "count": 3,
    "results": [
        {
            "ruleset_id": "ruleset-1",
            "rule_total_count": 1,
            "rule_criteria_types_counts": {
                "exact": 1
            }
        },
        {
            "ruleset_id": "ruleset-2",
            "rule_total_count": 2,
            "rule_criteria_types_counts": {
                "exact": 1,
                "fuzzy": 1
            }
        },
        {
            "ruleset_id": "ruleset-3",
            "rule_total_count": 3,
            "rule_criteria_types_counts": {
                "exact": 1,
                "fuzzy": 2
            }
        }
    ]
}
```

