Query rules

class elasticsearch_serverless.client.QueryRulesClient(client: BaseClient)
delete_rule(*, ruleset_id: str, rule_id: str, error_trace: bool | None = None, filter_path: str | Sequence[str] | None = None, human: bool | None = None, pretty: bool | None = None) ObjectApiResponse[Any]

Delete a query rule. Delete a query rule within a query ruleset. This is a destructive action that is only recoverable by re-adding the same rule with the create or update query rule API.

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-delete-rule

Parameters:
  • ruleset_id – The unique identifier of the query ruleset containing the rule to delete

  • rule_id – The unique identifier of the query rule within the specified ruleset to delete

delete_ruleset(*, ruleset_id: str, error_trace: bool | None = None, filter_path: str | Sequence[str] | None = None, human: bool | None = None, pretty: bool | None = None) ObjectApiResponse[Any]

Delete a query ruleset. Remove a query ruleset and its associated data. This is a destructive action that is not recoverable.

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-delete-ruleset

Parameters:

ruleset_id – The unique identifier of the query ruleset to delete

get_rule(*, ruleset_id: str, rule_id: str, error_trace: bool | None = None, filter_path: str | Sequence[str] | None = None, human: bool | None = None, pretty: bool | None = None) ObjectApiResponse[Any]

Get a query rule. Get details about a query rule within a query ruleset.

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-get-rule

Parameters:
  • ruleset_id – The unique identifier of the query ruleset containing the rule to retrieve

  • rule_id – The unique identifier of the query rule within the specified ruleset to retrieve

get_ruleset(*, ruleset_id: str, error_trace: bool | None = None, filter_path: str | Sequence[str] | None = None, human: bool | None = None, pretty: bool | None = None) ObjectApiResponse[Any]

Get a query ruleset. Get details about a query ruleset.

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-get-ruleset

Parameters:

ruleset_id – The unique identifier of the query ruleset

list_rulesets(*, error_trace: bool | None = None, filter_path: str | Sequence[str] | None = None, from_: int | None = None, human: bool | None = None, pretty: bool | None = None, size: int | None = None) ObjectApiResponse[Any]

Get all query rulesets. Get summarized information about the query rulesets.

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-list-rulesets

Parameters:
  • from – The offset from the first result to fetch.

  • size – The maximum number of results to retrieve.

put_rule(*, ruleset_id: str, rule_id: str, actions: Mapping[str, Any] | None = None, criteria: Mapping[str, Any] | Sequence[Mapping[str, Any]] | None = None, type: str | Literal['exclude', 'pinned'] | None = None, error_trace: bool | None = None, filter_path: str | Sequence[str] | None = None, human: bool | None = None, pretty: bool | None = None, priority: int | None = None, body: Dict[str, Any] | None = None) ObjectApiResponse[Any]

Create or update a query rule. Create or update a query rule within a query ruleset.

IMPORTANT: Due to limitations within pinned queries, you can only pin documents using ids or docs, but cannot use both in single rule. It is advised to use one or the other in query rulesets, to avoid errors. Additionally, pinned queries have a maximum limit of 100 pinned hits. If multiple matching rules pin more than 100 documents, only the first 100 documents are pinned in the order they are specified in the ruleset.

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-put-rule

Parameters:
  • ruleset_id – The unique identifier of the query ruleset containing the rule to be created or updated.

  • rule_id – The unique identifier of the query rule within the specified ruleset to be created or updated.

  • actions – The actions to take when the rule is matched. The format of this action depends on the rule type.

  • criteria – The criteria that must be met for the rule to be applied. If multiple criteria are specified for a rule, all criteria must be met for the rule to be applied.

  • type – The type of rule.

  • priority

put_ruleset(*, ruleset_id: str, rules: Mapping[str, Any] | Sequence[Mapping[str, Any]] | None = None, error_trace: bool | None = None, filter_path: str | Sequence[str] | None = None, human: bool | None = None, pretty: bool | None = None, body: Dict[str, Any] | None = None) ObjectApiResponse[Any]

Create or update a query ruleset. There is a limit of 100 rules per ruleset. This limit can be increased by using the xpack.applications.rules.max_rules_per_ruleset cluster setting.

IMPORTANT: Due to limitations within pinned queries, you can only select documents using ids or docs, but cannot use both in single rule. It is advised to use one or the other in query rulesets, to avoid errors. Additionally, pinned queries have a maximum limit of 100 pinned hits. If multiple matching rules pin more than 100 documents, only the first 100 documents are pinned in the order they are specified in the ruleset.

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-put-ruleset

Parameters:
  • ruleset_id – The unique identifier of the query ruleset to be created or updated.

  • rules

test(*, ruleset_id: str, match_criteria: Mapping[str, Any] | None = None, error_trace: bool | None = None, filter_path: str | Sequence[str] | None = None, human: bool | None = None, pretty: bool | None = None, body: Dict[str, Any] | None = None) ObjectApiResponse[Any]

Test a query ruleset. Evaluate match criteria against a query ruleset to identify the rules that would match that criteria.

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-test

Parameters:
  • ruleset_id – The unique identifier of the query ruleset to be created or updated

  • match_criteria – The match criteria to apply to rules in the given query ruleset. Match criteria should match the keys defined in the criteria.metadata field of the rule.