# Mapping for a hash map

**URL:** <https://discuss.elastic.co/t/mapping-for-a-hash-map/18091>\
**Category:** Elasticsearch\
**Created:** [June 13, 2014, 8:59am UTC](https://discuss.elastic.co/t/mapping-for-a-hash-map/18091 "2014-06-13T08:59:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manuel\_Vacelet\_2](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@Manuel\_Vacelet\_2](https://discuss.elastic.co/u/Manuel_Vacelet_2)\
**Post date:** [June 13, 2014, 8:59am UTC](https://discuss.elastic.co/t/mapping-for-a-hash-map/18091/1 "2014-06-13T08:59:27Z")

</div>

Hi there,

I'd like to define a mapping for a hash map but I do not manage to get it  
right.  
Here is the kind of documents I'd like to index:  
{  
"message" : "Elasticsearch test 1",  
"dates": {  
"create": "2014-01-11",  
"update": "2014-06-12"  
}  
}

{  
"message" : "Elasticsearch test 2",  
"dates": {  
"date\_1": "2014-01-11",  
}  
}

Note: date\_1 is on purpose, I cannot know at mapping definition how many  
dates I will have to deal with.

As is, without mapping it works automagically (probably thanks to type  
autodetection) but is there a mean to get it done without ?

My problem is that I might have stuff like that too:  
{  
"message" : "Elasticsearch test 3",  
"strings": {  
"string\_1": "some text",  
"string\_2": "2014-01-11"  
}  
}

{  
"message" : "Elasticsearch test 4",  
"strings": {  
"string\_2": "some other text"  
}  
}

In this case I need to be able to enforce that string\_2 is not a date

What is the right way to do it ?  
Manuel

--  
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/f45de373-4b57-4550-b9ae-c68d71dcf459%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f45de373-4b57-4550-b9ae-c68d71dcf459%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:22am UTC](https://discuss.elastic.co/t/mapping-for-a-hash-map/18091/2 "2017-07-06T01:22:48Z")

</div>


