Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support index templates to configure search replicas #17033

Open
vinaykpud opened this issue Jan 15, 2025 · 2 comments
Open
Labels
enhancement Enhancement or improvement to existing feature or request Search:Performance untriaged

Comments

@vinaykpud
Copy link
Contributor

Is your feature request related to a problem? Please describe

Currently index templates don't support adding search replicas for an index.
existing doc: https://opensearch.org/docs/latest/im-plugin/index-templates/

Describe the solution you'd like

Index templates should support format like this we can configure number_of_search_only_replicas

PUT _index_template/daily_logs
{
  "index_patterns": [
    "logs-2020-01-*"
  ],
  "template": {
    "aliases": {
      "my_logs": {}
    },
    "settings": {
      "number_of_shards": 2,
      "number_of_replicas": 1,
      "number_of_search_only_replicas": 1
    },
    "mappings": {
      "properties": {
        "timestamp": {
          "type": "date",
          "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
        },
        "value": {
          "type": "double"
        }
      }
    }
  }
}

Related component

Search:Performance

Describe alternatives you've considered

No response

Additional context

No response

@vinaykpud vinaykpud added enhancement Enhancement or improvement to existing feature or request untriaged labels Jan 15, 2025
@mgodwan
Copy link
Member

mgodwan commented Jan 16, 2025

What are the challenges you see with this? Given this is a setting, index template should already be supporting this.

@vinaykpud
Copy link
Contributor Author

Hi @mgodwan,
We want to add support to define number_of_search_only_replicas, its not currently supported.

Created template:

curl -X PUT "localhost:9200/_index_template/daily_logs" \
-H "Content-Type: application/json" \
-d '{
  "index_patterns": [
    "logs-2020-01-*"
  ],
  "template": {
    "aliases": {
      "my_logs": {}
    },
    "settings": {
      "number_of_shards": 2,
      "number_of_replicas": 1,
      "number_of_search_only_replicas": 1
    },
    "mappings": {
      "properties": {
        "timestamp": {
          "type": "date",
          "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
        },
        "value": {
          "type": "double"
        }
      }
    }
  }
}'

Create index using above template:

curl -X PUT "localhost:9200/logs-2020-01-01" \
-H "Content-Type: application/json" \
-d '{}'

List shards:

 curl -X GET "localhost:9200/_cat/shards?v"
index           shard prirep state   docs store ip        node
logs-2020-01-01 0     p      STARTED    0  230b 127.0.0.1 runTask-1
logs-2020-01-01 0     r      STARTED    0    0b 127.0.0.1 runTask-2
logs-2020-01-01 1     p      STARTED    0  230b 127.0.0.1 runTask-0
logs-2020-01-01 1     r      STARTED    0  230b 127.0.0.1 runTask-2

Here we expect search shards to be created as we declared "number_of_search_only_replicas": 1 in the template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or improvement to existing feature or request Search:Performance untriaged
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants