Create filters API

edit

Instantiates a filter.

Request

edit

PUT _ml/filters/<filter_id>

Prerequisites

edit

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

Description

edit

A filter contains a list of strings. It can be used by one or more jobs. Specifically, filters are referenced in the custom_rules property of detector configuration objects. For more information, see Custom rules.

Path parameters

edit
<filter_id>
(Required, string) A string that uniquely identifies a filter.

Request body

edit
description
(Optional, string) A description of the filter.
items
(Required, array of strings) The items of the filter. A wildcard * can be used at the beginning or the end of an item. Up to 10000 items are allowed in each filter.

Examples

edit
resp = client.ml.put_filter(
    filter_id="safe_domains",
    description="A list of safe domains",
    items=[
        "*.google.com",
        "wikipedia.org"
    ],
)
print(resp)
response = client.ml.put_filter(
  filter_id: 'safe_domains',
  body: {
    description: 'A list of safe domains',
    items: [
      '*.google.com',
      'wikipedia.org'
    ]
  }
)
puts response
const response = await client.ml.putFilter({
  filter_id: "safe_domains",
  description: "A list of safe domains",
  items: ["*.google.com", "wikipedia.org"],
});
console.log(response);
PUT _ml/filters/safe_domains
{
  "description": "A list of safe domains",
  "items": ["*.google.com", "wikipedia.org"]
}

When the filter is created, you receive the following response:

{
  "filter_id": "safe_domains",
  "description": "A list of safe domains",
  "items": ["*.google.com", "wikipedia.org"]
}