# Failing to PUT in an Index Template

**URL:** <https://discuss.elastic.co/t/failing-to-put-in-an-index-template/140563>\
**Category:** Elasticsearch\
**Created:** [July 18, 2018, 1:13pm UTC](https://discuss.elastic.co/t/failing-to-put-in-an-index-template/140563 "2018-07-18T13:13:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spitza\_Spitza](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Spitza\_Spitza](https://discuss.elastic.co/u/Spitza_Spitza)\
**Post date:** [July 18, 2018, 1:13pm UTC](https://discuss.elastic.co/t/failing-to-put-in-an-index-template/140563/1 "2018-07-18T13:13:04Z")

</div>

Using version 6.3.  
I tried to update /\_template/logstash with  
"index.number\_of\_replicas": "0"  
So I took the one I have now

```
{
  "logstash": {
    "order": 0,
    "version": 60001,
    "index_patterns": [
      "logstash-*"
    ],
    "settings": {
      "index": {
        "refresh_interval": "5s"
      }
    },
    "mappings": {
      "_default_": {
        "dynamic_templates": [
          {
            "message_field": {
              "path_match": "message",
              "match_mapping_type": "string",
              "mapping": {
                "type": "text",
                "norms": false
              }
            }
          },
          {
            "string_fields": {
              "match": "*",
              "match_mapping_type": "string",
              "mapping": {
                "type": "text",
                "norms": false,
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          }
        ],
        "properties": {
          "@timestamp": {
            "type": "date"
          },
          "@version": {
            "type": "keyword"
          },
          "geoip": {
            "dynamic": true,
            "properties": {
              "ip": {
                "type": "ip"
              },
              "location": {
                "type": "geo_point"
              },
              "latitude": {
                "type": "half_float"
              },
              "longitude": {
                "type": "half_float"
              }
            }
          }
        }
      }
    },
    "aliases": {}
  }
}

```

So I changed it to

```
PUT _template/logstash
{
  "logstash": {
    "order": 0,
    "version": 60001,
    "index_patterns": [
      "logstash-*"
    ],
    "settings": {
      "index.number_of_replicas": "0",
      "index": {
      "refresh_interval": "5s"
      }
    },
    "mappings": {
      "_default_": {
        "dynamic_templates": [
          {
            "message_field": {
              "path_match": "message",
              "match_mapping_type": "string",
              "mapping": {
                "type": "text",
                "norms": false
              }
            }
          },
          {
            "string_fields": {
              "match": "*",
              "match_mapping_type": "string",
              "mapping": {
                "type": "text",
                "norms": false,
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          }
        ],
        "properties": {
          "@timestamp": {
            "type": "date"
          },
          "@version": {
            "type": "keyword"
          },
          "geoip": {
            "dynamic": true,
            "properties": {
              "ip": {
                "type": "ip"
              },
              "location": {
                "type": "geo_point"
              },
              "latitude": {
                "type": "half_float"
              },
              "longitude": {
                "type": "half_float"
              }
            }
          }
        }
      }
    },
    "aliases": {}
  }
}

```

And got the error msg:

```
{
  "error": {
"root_cause": [
  {
    "type": "action_request_validation_exception",
    "reason": "Validation Failed: 1: index patterns are missing;"
  }
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: index patterns are missing;"
  },
  "status": 400
}

```

Deleted the old template and tried it again, still the same error. Tried putting the old one back in and still the same error.

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [July 19, 2018, 2:10pm UTC](https://discuss.elastic.co/t/failing-to-put-in-an-index-template/140563/2 "2018-07-19T14:10:51Z")

</div>

The `"logstash" : {` at the start of the body should not be there. Try this instead:

```auto
PUT _template/logstash
{
  "order": 0,
  "version": 60001,
  "index_patterns": [
    "logstash-*"
  ],
  "settings": {
    "index.number_of_replicas": "0",
    "index": {
      "refresh_interval": "5s"
    }
  },
  "mappings": {
    "_default_": {
      "dynamic_templates": [
        {
          "message_field": {
            "path_match": "message",
            "match_mapping_type": "string",
            "mapping": {
              "type": "text",
              "norms": false
            }
          }
        },
        {
          "string_fields": {
            "match": "*",
            "match_mapping_type": "string",
            "mapping": {
              "type": "text",
              "norms": false,
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            }
          }
        }
      ],
      "properties": {
        "@timestamp": {
          "type": "date"
        },
        "@version": {
          "type": "keyword"
        },
        "geoip": {
          "dynamic": true,
          "properties": {
            "ip": {
              "type": "ip"
            },
            "location": {
              "type": "geo_point"
            },
            "latitude": {
              "type": "half_float"
            },
            "longitude": {
              "type": "half_float"
            }
          }
        }
      }
    }
  },
  "aliases": {}
}

```

By the way, you are defining a mapping for `_default_` in this index template. `_default_` is deprecated as [you can only have one document type per index as of version 6](https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html). Maybe you can change this into the actual document type that you will be using.

---

<div class="post-metadata">

**Author:** ![Spitza\_Spitza](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Spitza\_Spitza](https://discuss.elastic.co/u/Spitza_Spitza)\
**Post date:** [July 23, 2018, 11:40am UTC](https://discuss.elastic.co/t/failing-to-put-in-an-index-template/140563/3 "2018-07-23T11:40:34Z")

</div>

Thank you, it worked.  
I will also check out check out the `_default_`.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 20, 2018, 11:40am UTC](https://discuss.elastic.co/t/failing-to-put-in-an-index-template/140563/4 "2018-08-20T11:40:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
