How to properly define a hashmap in ElasticSearch How to properly define a hashmap in ElasticSearch elasticsearch elasticsearch

How to properly define a hashmap in ElasticSearch


Is there a way to properly define a hashmap in elastic search?

In terms of handling objects, Elasticsearch has the Object Type and the Nested Type. Nested objects are treated as separate documents and the documentation provides good examples for understanding the advantages (and disadvantages).

I think Elasticsearch's dynamic templates might be worth exploring for your case if you want to fine tune how new key value pair additions are treated although you did mention the nested objects have a rigid definition?

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)

Are you referring to the large mappings that will get created? As you mentioned, that can be avoided with the Array type and so would it be possible to change the structure of your map object to avoid this? Or are the map keys not as simple as 1, 2, 3,...?


if you are not querying the field, you can set "enabled": false in mapping for that field

  "map": {    "type": "object",    "enabled": false  }