# Elasticsearch - add a constant mapping definition to a specific type in the mapping

**URL:** <https://discuss.elastic.co/t/elasticsearch-add-a-constant-mapping-definition-to-a-specific-type-in-the-mapping/28797>\
**Category:** Elasticsearch\
**Created:** [September 7, 2015, 8:51pm UTC](https://discuss.elastic.co/t/elasticsearch-add-a-constant-mapping-definition-to-a-specific-type-in-the-mapping/28797 "2015-09-07T20:51:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stam585](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@stam585](https://discuss.elastic.co/u/stam585)\
**Post date:** [September 7, 2015, 8:51pm UTC](https://discuss.elastic.co/t/elasticsearch-add-a-constant-mapping-definition-to-a-specific-type-in-the-mapping/28797/1 "2015-09-07T20:51:30Z")

</div>

I have the following mapping (static mapping)

```
{
	"settings": {},
	"mappings": {
		"MyEntity": {
			"properties": {
				"date": {
					"type": "date",
					"format": "dateOptionalTime"
				},
				"name": {
					"type": "string",
				},
				"tweet": {
					"type": "string"
				},
				"user_id": {
					"type": "long"
				}
			}
		}
	}
}

```

where "MyEntity" is an example of one of many entities.  
What I want is that every time an entity has the value:

```
"name": { 
      "type": "string",
 },

```

It will add the following

```
"name": {
	"type": "string",
	"analyzer": "mm_name_analyzer",
	"fields": {
		"lc": {
			"type": "string",
			"analyzer": "case_insensitive_sort"
		},
		"raw": {
			"type": "string",
			"index": "not_analyzed"
		}
	}
}

```

Is there a way to do it?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 7, 2015, 11:54pm UTC](https://discuss.elastic.co/t/elasticsearch-add-a-constant-mapping-definition-to-a-specific-type-in-the-mapping/28797/2 "2015-09-07T23:54:18Z")

</div>

That's a [multifield](https://www.elastic.co/guide/en/elasticsearch/guide/current/most-fields.html#_multifield_mapping) which should work fine, have you tried it?

---

<div class="post-metadata">

**Author:** ![stam585](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@stam585](https://discuss.elastic.co/u/stam585)\
**Post date:** [September 8, 2015, 6:38am UTC](https://discuss.elastic.co/t/elasticsearch-add-a-constant-mapping-definition-to-a-specific-type-in-the-mapping/28797/3 "2015-09-08T06:38:56Z")

</div>

@warkolm: Thanks.I am trying to add multi fields to an entity.  
Thing is - my template is static.

Lets say I have many types of entities as in "My\_Entity" (as in the example in the link).  
And I want to add to all the properties of type string this settings -  
If my mapping is not dynamic - I can't set is with the dynamic template feature.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 8, 2015, 8:09am UTC](https://discuss.elastic.co/t/elasticsearch-add-a-constant-mapping-definition-to-a-specific-type-in-the-mapping/28797/4 "2015-09-08T08:09:14Z")

</div>

Then you're stuck, you either need to move to dynamic or stick with what you have. There is no way to do a bit of each.

---

<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 5, 2017, 11:51pm UTC](https://discuss.elastic.co/t/elasticsearch-add-a-constant-mapping-definition-to-a-specific-type-in-the-mapping/28797/5 "2017-07-05T23:51:42Z")

</div>


