I am using dynamic mapping in ElasticSearch.
I use it because my index is long and I need to use the template feature in order to avoid updating definitions in multiple places (My other question here).
I am sending the following json (Object Zoo) which contains a HashMap as an example:
Put 127.0.0.1:9200/myIndex/Zoo/10
{
"id" : 1,
"Name" : "Madagascar",
"map" : {
"1" : {
"id" : -4944060986111146989,
"name" : null
},
"2" : {
"id" : 5073063561743125202,
"name" : null
},
"3" : {
"id" : -1777985506870671559,
"name" : null
}
}
}
This creates the following Index
{
"mm3_v2": {
"mappings": {
"Zoo": {
"properties": {
"Name": {
"type": "string"
},
"id": {
"type": "long"
},
"map": {
"properties": {
"1": {
"properties": {
"id": {
"type": "long"
}
}
},
"2": {
"properties": {
"id": {
"type": "long"
}
}
},
"3": {
"properties": {
"id": {
"type": "long"
}
}
}
}
}
}
}
}
}
}
In this example the inner object in the hashmap is short.
In real life my hashmap's object can be long.
This can create a huge index files (easily 1M rows) and for each object it repeats exactly the same definition.
(e.g. when stored in a List, the mapping does not repeat itself)
Is there a way to properly define a hashmap in elastic search?