Help Center> Cloud Search Service> User Guide> OpenSearch> Managing Indexes> Creating and Managing Index Policies
Updated on 2024-04-19 GMT+08:00

Creating and Managing Index Policies

You can manage the indexes of OpenSearch clusters. ISM is a plugin that allows you to automate periodic and administrative operations based on changes on the index age, index size, or number of documents. When using the ISM plug-in, you can define policies that automatically handle index rollovers or deletions based on your needs.

Creating an Index Policy

  1. Log in to Kibana and choose or Index Management on the left. The index management page is displayed.
  2. Click Create policy to create an index policy.
  3. In the Configuration method dialog box, select JSON editor and click Continue. The page for creating an index policy is displayed.
  4. Enter a policy ID in the Policy ID text box and enter your policy in the Define policy text box.
    Figure 1 Configuring a policy
  5. Click Create.

Attaching a Policy to an Index

You can attach a policy to one or more indexes and add the policy ID to an index template. When you create indexes using that index template pattern, the policy will be attached to all created indexes.

  • Method 1: OpenSearch Dashboard CLI

    On the Dev Tools page of the OpenSearch Dashboards, run the following command to associate the policy ID with the index template:

    PUT _template/<template_name> 
    {
        "index_patterns": ["index_name-*"],
        "settings": {
            "opendistro.index_state_management.policy_id": "policy_id"
        }
    }
    • <template_name>: Replace it with the name of a created index template.
    • policy_id: Replace it with a custom policy ID.

    For details about how to create an index template, see Index Templates.

  • Method 2: OpenSearch Dashboards Console
    1. On the Index Management page of the OpenSearch Dashboards, choose Indices.
      Figure 2 Choosing Indices
    2. In the Indices list, select the target index to which you want to attach a policy.
    3. Click Apply policy in the upper right corner.
      Figure 3 Adding a policy
    4. Select the policy you created from the Policy ID drop-down list.
      Figure 4 Selecting an index policy
    5. Click Apply.

      After you attach a policy to an index, ISM creates a job that runs every 5 minutes by default, to execute the policy, check conditions, and convert the index to different statuses.

Managing Index Policies

  1. On the Index Management page of the OpenSearch Dashboards, choose Managed Indices.
  2. If you want to change the policy, click Change policy. For details, see Changing Policies.
    Figure 5 Changing policies
  3. To delete a policy, select your policy, and click Remove policy.
  4. To retry a policy, select your policy, and click Retry policy.

For details, see Index State Management.