Create or update a query rule
Added in 8.15.0
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.
Path parameters
-
ruleset_id
string Required The unique identifier of the query ruleset containing the rule to be created or updated.
-
rule_id
string Required The unique identifier of the query rule within the specified ruleset to be created or updated.
Body
Required
-
type
string Required Values are
pinned
orexclude
. criteria
object | array[object] Required 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.
-
actions
object Required Additional properties are allowed.
-
priority
number
curl \
--request PUT http://api.example.com/_query_rules/{ruleset_id}/_rule/{rule_id} \
--header "Authorization: $API_KEY" \
--header "Content-Type: application/json" \
--data '{"type":"pinned","criteria":{"type":"global","metadata":"string","values":[{}]},"actions":{"ids":["string"],"docs":[{"_id":"string","_index":"string"}]},"priority":42.0}'