How to define dynamically / override the _default_ mapping in elasticsearch?

Viewed 1031

Use case :

  1. The index/indices will be built dynamically from a template, so that it will pick some custom settings (number of shards/replicas/ etc).
  2. Generate dynamically the types and their mappings, enabling for them all the timestamp & ttl fields. Also define the same parent type for all types, except the parent type itself (I know its name).

    {
       "template": "*",
    
       "settings": {
          ...................
       },
    
       "mappings": {
    
          "_default_": {
             "_parent": {
                "type": "ParentType"
             },
             "_timestamp": {
                "enabled": true,
                "store": true
             },
             "_ttl": {
                "enabled": true
             }
          }
    
       }
    }
    

How could I disable the _parent field for the ParentType type itself ?

1 Answers
Related