Create or update a query rule Added in 8.15.0

PUT /_query_rules/{ruleset_id}/_rule/{rule_id}

Create or update a query rule within a query 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

application/json

Body Required

  • type string Required

    Values are pinned or exclude.

  • criteria object | array[object] Required

    One of:
    Hide attributes Show attributes object
    • type string Required

      Values are global, exact, exact_fuzzy, fuzzy, prefix, suffix, contains, lt, lte, gt, gte, or always.

    • metadata string
    • values array[object]

      Additional properties are allowed.

  • actions object Required

    Additional properties are allowed.

    Hide actions attributes Show actions attributes object
    • ids array[string]
    • docs array[object]
      Hide docs attributes Show docs attributes object
  • priority number

Responses

  • 200 application/json
    Hide response attribute Show response attribute object
    • result string Required

      Values are created, updated, deleted, not_found, or noop.

PUT /_query_rules/{ruleset_id}/_rule/{rule_id}
curl \
 -X PUT http://api.example.com/_query_rules/{ruleset_id}/_rule/{rule_id} \
 -H "Content-Type: application/json" \
 -d '{"type":"pinned","criteria":{"type":"global","metadata":"string","values":[{}]},"actions":{"ids":["string"],"docs":[{"_id":"string","_index":"string"}]},"priority":42.0}'
Request examples
{
  "type": "pinned",
  "criteria": {
    "type": "global",
    "metadata": "string",
    "values": [
      {}
    ]
  },
  "actions": {
    "ids": [
      "string"
    ],
    "docs": [
      {
        "_id": "string",
        "_index": "string"
      }
    ]
  },
  "priority": 42.0
}
Response examples (200)
{
  "result": "created"
}