opensearch-project / opensearch-project/OpenSearch

[Feature Request] Possibility to name an alias with the dynamic part of a template pattern

Open
#20,122 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Indexing
Dominant language
Java
Stars
13.7k
Forks
3k
Avg merge
2d 23h
Merged PRs (30d)
108

Description

Is your feature request related to a problem? Please describe

In my company we use opensearch for multiple types of documents in different indexes for multiple clients. So we have templates for each kind of document and an alias for the client used for search, using the client id on the name i.e for the client_id 8 we would have the indexes: files-8, records-8… and the alias: client-8 assigned to files-8, records-8….

We have templates for each kind of document with pattern: files-, records-… But there is no way to assign the alias on the template as I would need to capture the dynamic part so we could assign the newly created index to the client alias, but we could not find an option to assign it to the regex segment captured on the index pattern.

This forces us to manually assign the alias for each index to each client. Or, as the indexes are automatically created based on the template, check on each index operation if the alias is assigned and assign it otherwise, which is not ideal.

Describe the solution you'd like

that could be done with a syntax like that maybe

"template": {
  "aliases": {
     "client-$1": {}
  }
}

where "$1" is the captured pattern by the * part of the index_pattern.

I found this reference of something that resembles of dynamically assigning a name to the index based on template, that would go something like:

PUT /_index_template/alias-template
{
  "index_patterns": [
    "something*"
  ],
  "template": {
    "settings": {
      "number_of_shards": 1
    },
    "aliases": {
      "{index}-alias": {}
    }
  }
}

but I could find no reference on documentation as how this semantics work, I tested it and it swaps the "{index}" part with the name of the index. It’s not what I need but would indicate that there is already a similar feature that could facilitate my feature suggestion.

Related component

Indexing

Describe alternatives you've considered

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked index-template alias documentation and the existing {index} alias substitution behavior described in the issue. Determine how wildcard captures could be exposed to template aliases, then define the expected behavior for newly auto-created indexes and validate it with focused index-template tests.

Written by the indexing model from the issue text.

Assessment

Domain
backend, search
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.