Elasticsearch - Define and use an index template for a given pattern that satisfies a given set of requirements

PUT _index_template/students-template
{
  "index_patterns": [
    "students-*"
  ],
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 0
    }
  }
}
GET _index_template/students-template
PUT students-2022
GET students-2022
GET _cat/indices?v
DELETE students-2022
DELETE _index_template/students-template
PUT _component_template/mysettings
{
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 0
    }
  }
}
GET _component_template/mysettings
PUT _index_template/students-template
{
  "index_patterns": [
    "students-*"
  ],
  "composed_of": [
    "mysettings"
  ]
}
GET _index_template/students-template
PUT students-2022
GET students-2022
PUT students-2022/_doc/1
{
  "student-id": "1001",
  "name": "John Smith",
  "course": "Elastic Certified Engineer"
}
GET students-2022/_doc/1
# Cleanup if you wish to
DELETE students-2022
DELETE _index_template/students-template
DELETE _component_template/mysettings

THANKS

FOR

WATCHING

Elasticsearch - Define and use an index template for a given pattern that satisfies a given set of requirements

By Deepak Dubey

Elasticsearch - Define and use an index template for a given pattern that satisfies a given set of requirements

  • 617