# Template mapping not being applied

**URL:** <https://discuss.elastic.co/t/template-mapping-not-being-applied/269848>\
**Category:** Elasticsearch\
**Created:** [April 12, 2021, 8:07am UTC](https://discuss.elastic.co/t/template-mapping-not-being-applied/269848 "2021-04-12T08:07:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)\
**Post date:** [April 12, 2021, 8:07am UTC](https://discuss.elastic.co/t/template-mapping-not-being-applied/269848/1 "2021-04-12T08:07:25Z")

</div>

Hello

I am currently setting a mapping in my template but it seems to not be working.

My work flow is basically

Data -\> Logstash -\> Elasticsearch

In Logstash, I do NOT set a template SO it gets the default, which is under "Legacy index templates" called "logstash".

Under this template, Ive applied the mapping, so I am not sure why it doesnt work.

If I delete the index, force a mapping and then copy it back, it does indeed work but this isnt ideal to set for example in a cron.

There is something I am missing (probably obvious) but Im not seeing it right now.

Can someone lend a hand?

Thanks

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 12, 2021, 8:11am UTC](https://discuss.elastic.co/t/template-mapping-not-being-applied/269848/2 "2021-04-12T08:11:10Z")

</div>

Does your index names match what is specified in the template?

---

<div class="post-metadata">

**Author:** ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)\
**Post date:** [April 15, 2021, 8:58am UTC](https://discuss.elastic.co/t/template-mapping-not-being-applied/269848/3 "2021-04-15T08:58:42Z")

</div>

When I create a index, a default template is picked up, correct? So it shouldnt matter what it is named.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 15, 2021, 9:01am UTC](https://discuss.elastic.co/t/template-mapping-not-being-applied/269848/4 "2021-04-15T09:01:47Z")

</div>

The template contains a field that specified which indices it applies to. If your index does not match this the template will not be applied. It would help if you showed the parts of the index template that does not specify mappings.

---

<div class="post-metadata">

**Author:** ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)\
**Post date:** [April 15, 2021, 9:37am UTC](https://discuss.elastic.co/t/template-mapping-not-being-applied/269848/5 "2021-04-15T09:37:43Z")

</div>

Do you mean this:

```
{
  "_doc": {
	"dynamic_templates": [
	  {
		"message_field": {
		  "path_match": "message",
		  "mapping": {
			"norms": false,
			"type": "text"
		  },
		  "match_mapping_type": "string"
		}
	  },
	  {
		"string_fields": {
		  "mapping": {
			"norms": false,
			"type": "text",
			"fields": {
			  "keyword": {
				"ignore_above": 256,
				"type": "keyword"
			  }
			}
		  },
		  "match_mapping_type": "string",
		  "match": "*"
		}
	  }
	],
	"properties": {
	  "@timestamp": {
		"type": "date"
	  },
	  "geoip": {
		"dynamic": true,
		"properties": {
		  "ip": {
			"type": "ip"
		  },
		  "latitude": {
			"type": "half_float"
		  },
		  "location": {
			"type": "geo_point"
		  },
		  "longitude": {
			"type": "half_float"
		  }
		}
	  },
	  "@version": {
		"type": "keyword"
	  }
	}
  }
}

```

?

Else, sorry, but Im not understanding you

---

<div class="post-metadata">

**Author:** ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)\
**Post date:** [April 19, 2021, 7:41am UTC](https://discuss.elastic.co/t/template-mapping-not-being-applied/269848/6 "2021-04-19T07:41:56Z")

</div>

I implemented a workaround that seems to work...........I dont think its the solution but.

---

<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:** [May 17, 2021, 7:42am UTC](https://discuss.elastic.co/t/template-mapping-not-being-applied/269848/7 "2021-05-17T07:42:31Z")

</div>

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