Mapping multiple keys to the same name


We are looking to save a object in key value structure in the elastic and we encounter mapping issues.
are keys are generated dynamic and we would like them to only be saved once in the mapping to avoid mapping explosion
"scenes": {
"key_a": {
"in": 1,
"duration": 2
"key_b": {
"in": 3,
"duration": 4
"key_c": {
"in": 5,
"duration": 6

As we are looking at keys that are generated randomly, we would like them all to be mapped to a single key in the mapping i.e "key_*".

Dynamic templates doesn't solve our issue as the keys are still being saved separately. We would like to merge all keys to a single key.
It's worth mentioning that the fields need to be searchable.

Is it possible?

The structure will depend a fair bit on what types of searches and aggregations you need to do. For example, you could reformat the data to be something like

  "keyname": "a",
  "in": 3,
  "duration": 2

As to whether this works for your use case depends on what searches you need to run.

thx! we considered the option of changing our object but we wanted to check before if we can use our current structure without causing a mapping explosion.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.