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

**URL:** <https://discuss.elastic.co/t/how-to-match-the-pattern-of-index-type-in-6-x/123724>\
**Category:** Elasticsearch\
**Created:** [March 13, 2018, 11:53am UTC](https://discuss.elastic.co/t/how-to-match-the-pattern-of-index-type-in-6-x/123724 "2018-03-13T11:53:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasad\_kp](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@prasad\_kp](https://discuss.elastic.co/u/prasad_kp)\
**Post date:** [March 13, 2018, 11:53am UTC](https://discuss.elastic.co/t/how-to-match-the-pattern-of-index-type-in-6-x/123724/1 "2018-03-13T11:53:07Z")

</div>

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 )

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 13, 2018, 12:06pm UTC](https://discuss.elastic.co/t/how-to-match-the-pattern-of-index-type-in-6-x/123724/2 "2018-03-13T12:06:58Z")

</div>

> [@prasad\_kp](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![prasad\_kp](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@prasad\_kp](https://discuss.elastic.co/u/prasad_kp)\
**Post date:** [March 13, 2018, 12:28pm UTC](https://discuss.elastic.co/t/how-to-match-the-pattern-of-index-type-in-6-x/123724/3 "2018-03-13T12:28:29Z")

</div>

So all the indices will have the type name **doc**?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 13, 2018, 12:32pm UTC](https://discuss.elastic.co/t/how-to-match-the-pattern-of-index-type-in-6-x/123724/4 "2018-03-13T12:32:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![prasad\_kp](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@prasad\_kp](https://discuss.elastic.co/u/prasad_kp)\
**Post date:** [March 13, 2018, 12:34pm UTC](https://discuss.elastic.co/t/how-to-match-the-pattern-of-index-type-in-6-x/123724/5 "2018-03-13T12:34:27Z")

</div>

> [@Christian\_Dahlqvist](#):
>
> that contains the type so that you can filter

okay Thanks Alot !!! @Christian_Dahlqvist

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 10, 2018, 12:34pm UTC](https://discuss.elastic.co/t/how-to-match-the-pattern-of-index-type-in-6-x/123724/6 "2018-04-10T12:34:45Z")

</div>

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