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

# Get all query rulesets

Availability:

## Paths

- `GET` `/_query_rules`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/authentication#apikeyauth)

## Description

Get summarized information about the query rulesets.

## Required authorization

* Cluster privileges: `manage_search_query_rules`

[About seeing rules and rulesets](https://www.elastic.co/docs/solutions/search/query-rules-ui#accessing-the-query-rules-ui)

## Query String Parameters

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

## Response

`application/json`

- `count` (number)
- `results` ([] QueryRulesetListItem)
  - `ruleset_id` (string Id)
    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
            }
        }
    ]
}
```

