# Correct mapping for a Java HashMap

**URL:** <https://discuss.elastic.co/t/correct-mapping-for-a-java-hashmap/15214>\
**Category:** Elasticsearch\
**Created:** [January 12, 2014, 4:14pm UTC](https://discuss.elastic.co/t/correct-mapping-for-a-java-hashmap/15214 "2014-01-12T16:14:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Webber](https://avatars.discourse-cdn.com/v4/letter/p/c77e96/32.png) [@Peter\_Webber](https://discuss.elastic.co/u/Peter_Webber)\
**Post date:** [January 12, 2014, 4:14pm UTC](https://discuss.elastic.co/t/correct-mapping-for-a-java-hashmap/15214/1 "2014-01-12T16:14:36Z")

</div>

I had a look at the mapping ES craeted outomatically for one of my indeces,  
and found something that's not quite right:

....  
"annotations" : {  
"properties" : {  
"ids" : {  
"properties" : {  
"hashMap" : {  
"properties" : {  
"N\_10290607" : {  
"type" : "double"  
},  
"A\_1038408" : {  
"type" : "double"  
},  
"A\_11585994" : {  
"type" : "double"  
},  
"B\_1245677" : {  
"type" : "double"  
},  
"B\_1269810" : {  
"type" : "double"  
},  
"C\_15680034" : {  
"type" : "double"  
},  
"N\_1654171" : {  
"type" : "double"  
},  
...

I use Gson to convert Java classes to Json and then directly put them into  
ES. One of the classes I use has a HashMap\<String, Double\> as a central  
piece, where it stores its key-value pairs. It's really just that: the keys  
are stings, the values doubles. ES however creates a mapping for every key  
of the hashmap as you can see above.

Does someone here knoe what mapping I need to define to avoid that?

Also: Can I change this mapping on the already existing index, or do I have  
to create a new index, then create a mapping, then copy over the data from  
the old index?

Many Thanks!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5ca0d658-7332-4c82-8e5b-2f767a230c64%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5ca0d658-7332-4c82-8e5b-2f767a230c64%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 1:57am UTC](https://discuss.elastic.co/t/correct-mapping-for-a-java-hashmap/15214/2 "2017-07-06T01:57:13Z")

</div>


