123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- [role="xpack"]
- [[list-query-rulesets]]
- === List query rulesets
- preview::[]
- ++++
- <titleabbrev>List query rulesets</titleabbrev>
- ++++
- 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": "pinned",
- "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
- }
- },
- {
- "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
- }
- }
- ]
- }
- ----
- // 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.
|