Lionel Tressens
Lionel Tressens

Reputation: 481

ElasticSearch 8 : mapping template not applied to indices

I create an index template affecting all indices matching "shoppers-*" but then, when creating an index of this name format, the template is not applied, the mapping is not retrieved.

  1. create template
PUT /_index_template/my-template
{
  "index_patterns": [
    "shoppers-*"
  ],
  "template": {
    "mappings": {
      "properties": {
        "shopper": {
          "properties": {
            "tag": {
              "type": "keyword"
            }
          }
        }
      }
    },
    "aliases": {
      "my-template-alias": {}
    }
  }
}
{
  "acknowledged": true
}
  1. then create an index
PUT /shoppers-0001
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "shoppers-0001"
}
  1. refresh
POST /shoppers-0001/_refresh
{
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  }
}
  1. retrieve mapping on the newly created index
GET /shoppers-0001/_mapping
{
  "shoppers-0001": {
    "mappings": {}
  }
}

I cannot figure what could prevent the template to be applied to this index... Any things I may check to help debug this?

Upvotes: 0

Views: 522

Answers (1)

Lionel Tressens
Lionel Tressens

Reputation: 481

Writing the problem after so many hours looking for an answer took me to the solution ! I am answering my own question for those who are going to read this question later with the same problem.

There were another template matching pattern * and having precedence over my template !

Upvotes: 1

Related Questions