Update filters API

Update filters API

New API reference

For the most up-to-date API details, refer to Machine learning anomaly detection APIs.

Updates the description of a filter, adds items, or removes items.

Request

POST _ml/filters/<filter_id>/_update

Prerequisites

Requires the manage_ml cluster privilege. This privilege is included in the machine_learning_admin built-in role.

Path parameters

<filter_id>

(Required, string) A string that uniquely identifies a filter.

Request body

add_items

(Optional, array of strings) The items to add to the filter.

description

(Optional, string) A description for the filter.

remove_items

(Optional, array of strings) The items to remove from the filter.

Examples

  1. resp = client.ml.update_filter(
  2. filter_id="safe_domains",
  3. description="Updated list of domains",
  4. add_items=[
  5. "*.myorg.com"
  6. ],
  7. remove_items=[
  8. "wikipedia.org"
  9. ],
  10. )
  11. print(resp)
  1. response = client.ml.update_filter(
  2. filter_id: 'safe_domains',
  3. body: {
  4. description: 'Updated list of domains',
  5. add_items: [
  6. '*.myorg.com'
  7. ],
  8. remove_items: [
  9. 'wikipedia.org'
  10. ]
  11. }
  12. )
  13. puts response
  1. const response = await client.ml.updateFilter({
  2. filter_id: "safe_domains",
  3. description: "Updated list of domains",
  4. add_items: ["*.myorg.com"],
  5. remove_items: ["wikipedia.org"],
  6. });
  7. console.log(response);
  1. POST _ml/filters/safe_domains/_update
  2. {
  3. "description": "Updated list of domains",
  4. "add_items": ["*.myorg.com"],
  5. "remove_items": ["wikipedia.org"]
  6. }

The API returns the following results:

  1. {
  2. "filter_id": "safe_domains",
  3. "description": "Updated list of domains",
  4. "items": ["*.google.com", "*.myorg.com"]
  5. }