mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-25 07:37:19 -04:00
221 lines
4.8 KiB
Text
221 lines
4.8 KiB
Text
[role="xpack"]
|
|
[[list-query-rulesets]]
|
|
=== List query rulesets
|
|
|
|
++++
|
|
<titleabbrev>List query rulesets</titleabbrev>
|
|
++++
|
|
|
|
.New API reference
|
|
[sidebar]
|
|
--
|
|
For the most up-to-date API details, refer to {api-es}/group/endpoint-query_rules[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.
|
|
|
|
[[list-query-rules-request]]
|
|
==== {api-request-title}
|
|
|
|
`GET _query_rules/`
|
|
|
|
[[list-query-rules-prereq]]
|
|
==== {api-prereq-title}
|
|
|
|
Requires the `manage_search_query_rules` privilege.
|
|
|
|
[[list-query-rules-path-params]]
|
|
==== {api-path-parms-title}
|
|
|
|
`size`::
|
|
(Optional, integer) Maximum number of results to retrieve.
|
|
|
|
`from`::
|
|
(Optional, integer) The offset from the first result to fetch.
|
|
|
|
[[list-query-rules-example]]
|
|
==== {api-examples-title}
|
|
|
|
The following example lists all configured query rulesets:
|
|
|
|
////
|
|
|
|
[source,console]
|
|
--------------------------------------------------
|
|
PUT _query_rules/ruleset-1
|
|
{
|
|
"rules": [
|
|
{
|
|
"rule_id": "rule-1",
|
|
"type": "pinned",
|
|
"criteria": [
|
|
{
|
|
"type": "exact",
|
|
"metadata": "query_string",
|
|
"values": [ "puggles" ]
|
|
}
|
|
],
|
|
"actions": {
|
|
"ids": ["id1"]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
|
|
PUT _query_rules/ruleset-2
|
|
{
|
|
"rules": [
|
|
{
|
|
"rule_id": "rule-1",
|
|
"type": "pinned",
|
|
"criteria": [
|
|
{
|
|
"type": "exact",
|
|
"metadata": "query_string",
|
|
"values": [ "puggles" ]
|
|
}
|
|
],
|
|
"actions": {
|
|
"ids": ["id1"]
|
|
}
|
|
},
|
|
{
|
|
"rule_id": "rule-2",
|
|
"type": "pinned",
|
|
"criteria": [
|
|
{
|
|
"type": "fuzzy",
|
|
"metadata": "query_string",
|
|
"values": [ "pugs" ]
|
|
}
|
|
],
|
|
"actions": {
|
|
"ids": ["id2"]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
|
|
PUT _query_rules/ruleset-3
|
|
{
|
|
"rules": [
|
|
{
|
|
"rule_id": "rule-1",
|
|
"type": "pinned",
|
|
"criteria": [
|
|
{
|
|
"type": "exact",
|
|
"metadata": "query_string",
|
|
"values": [ "puggles" ]
|
|
}
|
|
],
|
|
"actions": {
|
|
"ids": ["id1"]
|
|
}
|
|
},
|
|
{
|
|
"rule_id": "rule-2",
|
|
"type": "pinned",
|
|
"criteria": [
|
|
{
|
|
"type": "fuzzy",
|
|
"metadata": "query_string",
|
|
"values": [ "pugs" ]
|
|
}
|
|
],
|
|
"actions": {
|
|
"ids": ["id2"]
|
|
}
|
|
},
|
|
{
|
|
"rule_id": "rule-3",
|
|
"type": "exclude",
|
|
"criteria": [
|
|
{
|
|
"type": "fuzzy",
|
|
"metadata": "query_string",
|
|
"values": [ "beagles" ]
|
|
}
|
|
],
|
|
"actions": {
|
|
"ids": ["id2"]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
--------------------------------------------------
|
|
// TESTSETUP
|
|
|
|
[source,console]
|
|
--------------------------------------------------
|
|
DELETE _query_rules/ruleset-1
|
|
|
|
DELETE _query_rules/ruleset-2
|
|
|
|
DELETE _query_rules/ruleset-3
|
|
|
|
--------------------------------------------------
|
|
// TEARDOWN
|
|
|
|
////
|
|
|
|
[source,console]
|
|
----
|
|
GET _query_rules/
|
|
----
|
|
|
|
The following example lists the first three query rulesets:
|
|
|
|
[source,console]
|
|
----
|
|
GET _query_rules/?from=0&size=3
|
|
----
|
|
|
|
A sample response:
|
|
|
|
[source,console-result]
|
|
----
|
|
{
|
|
"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
|
|
}
|
|
}
|
|
]
|
|
}
|
|
----
|
|
// TEST[continued]
|
|
|
|
[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.
|