[[reference-query_rules-put_rule]]

////////
===========================================================================================================================
||                                                                                                                       ||
||                                                                                                                       ||
||                                                                                                                       ||
||        ██████╗ ███████╗ █████╗ ██████╗ ███╗   ███╗███████╗                                                            ||
||        ██╔══██╗██╔════╝██╔══██╗██╔══██╗████╗ ████║██╔════╝                                                            ||
||        ██████╔╝█████╗  ███████║██║  ██║██╔████╔██║█████╗                                                              ||
||        ██╔══██╗██╔══╝  ██╔══██║██║  ██║██║╚██╔╝██║██╔══╝                                                              ||
||        ██║  ██║███████╗██║  ██║██████╔╝██║ ╚═╝ ██║███████╗                                                            ||
||        ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═════╝ ╚═╝     ╚═╝╚══════╝                                                            ||
||                                                                                                                       ||
||                                                                                                                       ||
||    This file is autogenerated, DO NOT send pull requests that changes this file directly.                             ||
||    You should update the script that does the generation, which can be found in:                                      ||
||    https://github.com/elastic/elastic-client-generator-js                                                             ||
||                                                                                                                       ||
||    You can run the script with the following command:                                                                 ||
||       npm run elasticsearch -- --version <version>                                                                    ||
||                                                                                                                       ||
||                                                                                                                       ||
||                                                                                                                       ||
===========================================================================================================================
////////

[discrete]
=== client.queryRules.putRule

Creates or updates a query rule within a query ruleset.

{ref}/put-query-rule.html[{es} documentation]

[discrete]
==== Function signature

[source,ts]
----
(QueryRulesPutRuleRequest, options?): Promise<QueryRulesPutRuleResponse>
----

[discrete]
===== `QueryRulesPutRuleRequest`

[source,ts]
----
interface QueryRulesPutRuleRequest extends <<shared-type-request-base, RequestBase>> {
  ruleset_id: <<shared-type-id, Id>>
  rule_id: <<shared-type-id, Id>>
  type: QueryRulesQueryRuleType
  criteria: QueryRulesQueryRuleCriteria | QueryRulesQueryRuleCriteria[]
  actions: QueryRulesQueryRuleActions
  priority?: <<shared-type-integer, integer>>
}
----

[discrete]
===== `QueryRulesPutRuleResponse`

[source,ts]
----
interface QueryRulesPutRuleResponse {
  result: <<shared-type-result, Result>>
}
----

