# Elasticsearch 2 mapping

**URL:** <https://discuss.elastic.co/t/elasticsearch-2-mapping/34366>\
**Category:** Elasticsearch\
**Created:** [November 12, 2015, 12:03am UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366 "2015-11-12T00:03:20Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![mramaprasad](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@mramaprasad](https://discuss.elastic.co/u/mramaprasad)\
**Post date:** [November 12, 2015, 12:03am UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/1 "2015-11-12T00:03:20Z")

</div>

Here is the mapping for acronym field and am running elsaticsearch 1.1.1.  
"isbnfield": {  
"type":"multi\_field",  
"fields":{  
"isbn":{"type":"string","index":"analyzed", "store" : true},  
"isbnuntouched":{"type":"string","index":"not\_analyzed", "store" : true}  
}   
},  
"acronymfield": {  
"type":"multi\_field",  
"fields":{  
"acronym":{"type":"string","index":"analyzed", "store" : true},  
"acronymuntouched":{"type":"string","index":"not\_analyzed", "store" : true}  
}  
},  
"abbrev": {  
"type": "string"  
}

I am trying to update o elaseticsearch 2.0 and I am getting the following error message for acronym field. What is the problem?

java.lang.IllegalStateException: unable to upgrade the mappings for the index [csv1], reason: [Field name [acronymfield.acronym] cannot contain '.']  
at org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeService.checkMappingsCompatibility(MetaDataIndexUpgradeService.java:335)  
at org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeService.upgradeIndexMetaData(MetaDataIndexUpgradeService.java:112)  
at org.elasticsearch.gateway.GatewayMetaState.pre20Upgrade(GatewayMetaState.java:226)  
at org.elasticsearch.gateway.GatewayMetaState.(GatewayMetaState.java:85)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 12, 2015, 3:28am UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/2 "2015-11-12T03:28:55Z")

</div>

I believe it's because "type: multifield" has been deprecated for a long time and is not supported anymore.

Are you upgrading from a very old version?

Did you try the migration plugin before upgrading? [https://github.com/elastic/elasticsearch-migration](https://github.com/elastic/elasticsearch-migration)

May you could open an issue so we can at the very least fix the documentation here: [https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking\_20\_mapping\_changes.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_20_mapping_changes.html) or try to find a way to read your mapping if doable.

For now, I'm afraid you have to create a new mapping and reindex.

---

<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:** [November 12, 2015, 3:38am UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/3 "2015-11-12T03:38:25Z")

</div>

Yes, because of [https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking\_20\_mapping\_changes.html#\_field\_names\_may\_not\_contain\_dots](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_20_mapping_changes.html#_field_names_may_not_contain_dots)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 12, 2015, 3:50am UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/4 "2015-11-12T03:50:47Z")

</div>

The problem here is that he is not using dot explicitly but the multifield type which is generating this dot.

---

<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:** [November 12, 2015, 4:00am UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/5 "2015-11-12T04:00:20Z")

</div>

Sorry, missed your reply somehow! 😃

---

<div class="post-metadata">

**Author:** ![mramaprasad](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@mramaprasad](https://discuss.elastic.co/u/mramaprasad)\
**Post date:** [November 12, 2015, 4:10pm UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/6 "2015-11-12T16:10:00Z")

</div>

Thanks for the responses.

I am upgrading from version 1.1.1 to 2.0.

When I created a mapping in 2.0 with the multi field it did not complain.

But only has problems if I had data and trying to upgrade the data.

---

<div class="post-metadata">

**Author:** ![mramaprasad](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@mramaprasad](https://discuss.elastic.co/u/mramaprasad)\
**Post date:** [November 12, 2015, 4:21pm UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/7 "2015-11-12T16:21:45Z")

</div>

How would the multi field be indexed in 2.0 version?

"acronymfield": {  
"type":"multi\_field",  
"fields":{  
"acronym":{"type":"string","index":"analyzed", "store" : true},  
"acronymuntouched":{"type":"string","index":"not\_analyzed", "store" : true}  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 12, 2015, 4:46pm UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/8 "2015-11-12T16:46:11Z")

</div>

Read [https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html)

---

<div class="post-metadata">

**Author:** ![mramaprasad](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@mramaprasad](https://discuss.elastic.co/u/mramaprasad)\
**Post date:** [November 16, 2015, 11:18pm UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/9 "2015-11-16T23:18:52Z")

</div>

I have updated the mapping to have in elasticsearch 1.1.1 and indexed the data.

```
           	"acronymfield" : {
            	"type" : "string",
            	"fields": {
            		"raw" : {
            			"type": "string",
            	 		"index": "not_analyzed"
            	 	 }
             	}	          
		    },	            

```

I was trying to upgrade to version 2.0 by starting elasticsearch2.0.

I still get the following error:

Exception in thread "main" java.lang.IllegalStateException: unable to upgrade the mappings for the index [csv3], reason: [Field name [acronymfield.raw] cannot contain '.']  
Likely root cause: MapperParsingException[Field name [acronymfield.raw] cannot contain '.']  
at org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:283)  
at org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseObjectOrDocumentTypeProperties(ObjectMapper.java:228)  
at org.elasticsearch.index.mapper.object.RootObjectMapper$TypeParser.parse(RootObjectMapper.java:137)  
at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:211)  
at org.elasticsearch.index.mapper.DocumentMapperParser.parseCompressed(DocumentMapperParser.java:192)  
at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:368)  
at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:242)  
at org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeService.checkMappingsCompatibility(MetaDataIndexUpgradeService.java:329)  
at org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeService.upgradeIndexMetaData(MetaDataIndexUpgradeService.java:112)  
at org.elasticsearch.gateway.GatewayMetaState.pre20Upgrade(GatewayMetaState.java:226)  
at org.elasticsearch.gateway.GatewayMetaState.(GatewayMetaState.java:85)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)  
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)  
at \<\<\>\>  
at org.elasticsearch.node.Node.(Node.java:198)  
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145)  
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170)  
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)  
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)

Any ideas please? Is it complaining about the "." in the data that is being indexed?

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 17, 2015, 1:06am UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/10 "2015-11-17T01:06:12Z")

</div>

This appears to be an expectation bug in Elasticsearch. Since 2.0, dots are  
no longer valid inside field names. However, the use of "fields" in the  
mapping will generate a field name with a dot. Elasticsearch needs to  
remove multi fields since they no longer allow dots in name. Even the  
example of multi fields still has a no longer relevant field name:

[https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html)

Try switching to copy\_to

[https://www.elastic.co/guide/en/elasticsearch/reference/current/copy-to.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/copy-to.html)

Ivan

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 17, 2015, 1:16am UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/11 "2015-11-17T01:16:16Z")

</div>

I do not have an Elasticsearch instance in front of me, so I cannot test,  
but I would be surprised if this truly is the bug. Judging by the test  
code, field names with dots are being generated.

> <https://github.com/elastic/elasticsearch/blob/2.0/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java#L88>

Strange.

Ivan

---

<div class="post-metadata">

**Author:** ![mramaprasad](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@mramaprasad](https://discuss.elastic.co/u/mramaprasad)\
**Post date:** [November 17, 2015, 4:37pm UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/12 "2015-11-17T16:37:28Z")

</div>

Objects fields in elasticsearch will have to be accessed by dot right? Are they valid in 2.0? We would have to use source.name to access the name field right?

"source" : {  
"name" : "book",  
"edition" : "1",  
"numberOfPages" : "240"  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 17, 2015, 6:17pm UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/13 "2015-11-17T18:17:17Z")

</div>

I agree with @Ivan. It looks like a bug.

So @mramaprasad if you could provide a full simple script with only `foo,bar,baz` things to reproduce the issue that would be super useful.

And yes, accessing to `source.name` should work. `source.name.raw` also...

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 17, 2015, 6:59pm UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/14 "2015-11-17T18:59:53Z")

</div>

It appears that the check for invalid names in the mapper service occurs  
only on the field name, so the old unit tests for multi field still work. I  
still do not have the code in front, looking at it only via Github, but I  
cannot find where the new name gets generated. Interesting problem.

Ivan

---

<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:37pm UTC](https://discuss.elastic.co/t/elasticsearch-2-mapping/34366/15 "2017-07-05T23:37:51Z")

</div>


