# Difference between "index\_patterns" and "template"

**URL:** <https://discuss.elastic.co/t/difference-between-index-patterns-and-template/184877>\
**Category:** Elasticsearch\
**Created:** [June 9, 2019, 1:47pm UTC](https://discuss.elastic.co/t/difference-between-index-patterns-and-template/184877 "2019-06-09T13:47:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adello](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@Adello](https://discuss.elastic.co/u/Adello)\
**Post date:** [June 9, 2019, 1:47pm UTC](https://discuss.elastic.co/t/difference-between-index-patterns-and-template/184877/1 "2019-06-09T13:47:14Z")

</div>

Hi ((:

What is the difference between those keywords when creating a mapping? For instance:

```
curl -XPUT 'localhost:9200/_template/template1?pretty' -H "Content-Type: application/json" -d '{
  "index_patterns": ["abc*"],
   "template": "abc*",
    "mappings": { "properties": { "age": { "type": "long" } } }
}'

```

Or can anyone point me to some documentation or good reference?

Thx (:

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [June 10, 2019, 1:19pm UTC](https://discuss.elastic.co/t/difference-between-index-patterns-and-template/184877/2 "2019-06-10T13:19:03Z")

</div>

`index_patterns` can be an array where as template could only be a single string with a simple regular expression. The original PR is here: [https://github.com/elastic/elasticsearch/pull/21009](https://github.com/elastic/elasticsearch/pull/21009)

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Adello](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@Adello](https://discuss.elastic.co/u/Adello)\
**Post date:** [June 10, 2019, 5:40pm UTC](https://discuss.elastic.co/t/difference-between-index-patterns-and-template/184877/3 "2019-06-10T17:40:51Z")

</div>

Thank you for your replay (: ... so basically `index_patterns`and `templates` provides the same functionality except that `index_patterns` can hold an array of indices where the template will be assigned?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [June 11, 2019, 7:14am UTC](https://discuss.elastic.co/t/difference-between-index-patterns-and-template/184877/4 "2019-06-11T07:14:06Z")

</div>

indeed. and newer elasticsearch verions require to use `index_patterns`

---

<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:** [July 9, 2019, 7:14am UTC](https://discuss.elastic.co/t/difference-between-index-patterns-and-template/184877/5 "2019-07-09T07:14:15Z")

</div>

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