How to match the pattern of index type in 6.X

I am using dynamic template

PUT _template/agg
{
  "index_patterns":["aggs*"],
  "settings": {
    "number_of_shards": 5,
    "number_of_replicas": 1
    
  },
  "mappings": {
    "pk*":{
      "_source": {
        "enabled": true
      },
      "dynamic_templates":[
        {
          "strings":{
            "match":"*",
            "match_mapping_type":"string",
            "mapping":{
              "type":"keyword"
            }
          }
        }
        
        ]
    }
  }
}

when i run the below query m getting the following exception

PUT aggs/pkp_order/1
{
  "name":"prasad"
}

"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [aggs] as the final mapping would have more than 1 type: [pkp_order, pk*]"

Do we need to fix the index type at the creation of template level only?

As in higher versions,one index can have one type only,but i have all the indices which starts with aggs & their index type starts with pkp_******(different names after pkp for diffrent indexes )

Why are you doing this instead of using a single common document type, e.g. doc?

If you are relying on this, you are setting yourself up for a more difficult migration when type is eventually removed completely.

1 Like

So all the indices will have the type name doc ?

Yes, that is what I would propose. If you need to tell different types of data apart, instead add an additional custom field to your data that contains the type so that you can filter on it.

okay Thanks Alot !!! @Christian_Dahlqvist

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