Mapping for object with dynamic keys

Have a document like this:

  {
       "stats": {
         "fruits.v:apple": 30,
         "fruits.v:orange": 150,
         "vegetables.v: broccoli": 40
       }
    } 
  1. Can I keep the key name as is? What kind of dynamic mapping will help in doing this?
  2. Is it possible to create dynamically fields like:
  {
      "stats": {
        "fruits": {
          "v": "apple",
          "count": 30
        }
      }
    }

Hi ab

Dot expander processor is what you are looking for https://www.elastic.co/guide/en/elasticsearch/reference/master/dot-expand-processor.html

It won't work with ":". If number of fruits / veggies are known then you can use rename processor.

Otherwise you will have to use script processor.

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