# How to define multiple index types mapping in single template

**URL:** <https://discuss.elastic.co/t/how-to-define-multiple-index-types-mapping-in-single-template/137370>\
**Category:** Elasticsearch\
**Created:** [June 26, 2018, 6:11am UTC](https://discuss.elastic.co/t/how-to-define-multiple-index-types-mapping-in-single-template/137370 "2018-06-26T06:11:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![yash\_mangla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yash_mangla/32/25889_2.png) [@yash\_mangla](https://discuss.elastic.co/u/yash_mangla)\
**Post date:** [June 26, 2018, 6:11am UTC](https://discuss.elastic.co/t/how-to-define-multiple-index-types-mapping-in-single-template/137370/1 "2018-06-26T06:11:02Z")

</div>

Hello Guyz,

I have default Template file of blueliv which was working on elasticsearch-6.2.3. but in 6.2.4 that mapping is not works.

I'm getting following error when i tried following [configuration](https://raw.githubusercontent.com/Blueliv/elk-config-examples/master/elasticsearch/template.json):

> `{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"No handler for type [string] declared on field [@version]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_default_]: No handler for type [string] declared on field [@version]","caused_by":{"type":"mapper_parsing_exception","reason":"No handler for type [string] declared on field [@version]"}},"status":400`

Could anyone help me to define new mappings which is compatible with elasticsearch-6.2.4.

Regards,  
Yash M.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 26, 2018, 6:31am UTC](https://discuss.elastic.co/t/how-to-define-multiple-index-types-mapping-in-single-template/137370/2 "2018-06-26T06:31:16Z")

</div>

Use `text` instead of `string`.

---

<div class="post-metadata">

**Author:** ![yash\_mangla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yash_mangla/32/25889_2.png) [@yash\_mangla](https://discuss.elastic.co/u/yash_mangla)\
**Post date:** [June 26, 2018, 6:42am UTC](https://discuss.elastic.co/t/how-to-define-multiple-index-types-mapping-in-single-template/137370/3 "2018-06-26T06:42:10Z")

</div>

Hello @dadoonet,

I changed the @version mapping to text but it seems like there is too many changes in 6.2.4. now after changing mapping `string` to ` text`.

i'm getting following error.

> `{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_default_]: Could not convert [@version.index] to boolean"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_default_]: Could not convert [@version.index] to boolean","caused_by":{"type":"illegal_argument_exception","reason":"Could not convert [@version.index] to boolean","caused_by":{"type":"illegal_argument_exception","reason":"Failed to parse value [not_analyzed] as only [true] or [false] are allowed."}}},"status":400}`

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 26, 2018, 6:55am UTC](https://discuss.elastic.co/t/how-to-define-multiple-index-types-mapping-in-single-template/137370/4 "2018-06-26T06:55:52Z")

</div>

I doubt you are seeing such a difference between `6.2.3` and `6.2.4`.

I believe that the template was there in 6.2.3 (like upgraded from a previous version) but you are trying to upgrade the template using a removed format.

What gives for now:

```auto
GET _template/YOUR_TEMPLATE_NAME 

```

---

<div class="post-metadata">

**Author:** ![yash\_mangla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yash_mangla/32/25889_2.png) [@yash\_mangla](https://discuss.elastic.co/u/yash_mangla)\
**Post date:** [June 26, 2018, 7:11am UTC](https://discuss.elastic.co/t/how-to-define-multiple-index-types-mapping-in-single-template/137370/5 "2018-06-26T07:11:44Z")

</div>

> [@dadoonet](#):
>
> I doubt you are seeing such a difference between `6.2.3` and `6.2.4` .
> 
> I believe that the template was there in 6.2.3 (like upgraded from a previous version) but you are trying to upgrade the template using a removed format.

Not exactly, I'm trying to made working the same template to 6.2.4 version. All this testing i'm doing in fresh instance of new VM.

In my last error, as i suspected `"_all"` & `index: 'not_analyzed'` mapping is deprecated in `6.2.4`.  
so i removed both the settings from my template file. but now i'm facing such weird issue.

> `{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [YeGfDJjeThiDFGQ1Qv6yDw] as the final mapping would have more than 1 type: [blueliv-malwares, blueliv-attacks]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [YeGfDJjeThiDFGQ1Qv6yDw] as the final mapping would have more than 1 type: [blueliv-malwares, blueliv-attacks]"},"status":400}`

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 26, 2018, 7:54am UTC](https://discuss.elastic.co/t/how-to-define-multiple-index-types-mapping-in-single-template/137370/6 "2018-06-26T07:54:26Z")

</div>

But you wrote:

> I have default Template file of blueliv which was working on elasticsearch-6.2.3. but in 6.2.4 that mapping is not works.

I doubt about this.

I mean that I doubt the same template works on 6.2.3 and not on 6.2.4.

ie. You can't not create a new index with multiple types from 6.0.  
Here the error message is about that.

---

<div class="post-metadata">

**Author:** ![yash\_mangla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yash_mangla/32/25889_2.png) [@yash\_mangla](https://discuss.elastic.co/u/yash_mangla)\
**Post date:** [June 26, 2018, 8:11am UTC](https://discuss.elastic.co/t/how-to-define-multiple-index-types-mapping-in-single-template/137370/7 "2018-06-26T08:11:32Z")

</div>

Hello @dadoonet,

I understand what error message is all about. it's rejecting my multiple type settings in same index. but I have doubt because **conceptually** ,

if we talk about normal database we can create as many tables as we want in a single database but in elasticsearch index acts like database and type is act like a table. if i consider conceptually. So, i can create as many type as we want.

If this is not the case then this update is conceptually wrong. then i want to know  
what concept is actually followed by elastic ? I am assuming elastic may be have other alternative to acheive multiple types in same index. but i don't know the exact mapping to do that.

So i want to know if there is other alternative is in place to acheive this concept ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 26, 2018, 8:29am UTC](https://discuss.elastic.co/t/how-to-define-multiple-index-types-mapping-in-single-template/137370/8 "2018-06-26T08:29:35Z")

</div>

It's another question than the original thread. But read this [https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html)

---

<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:** [June 26, 2018, 8:38am UTC](https://discuss.elastic.co/t/how-to-define-multiple-index-types-mapping-in-single-template/137370/9 "2018-06-26T08:38:42Z")

</div>

> [@yash\_mangla](#):
>
> if we talk about normal database we can create as many tables as we want in a single database but in elasticsearch index acts like database and type is act like a table. if i consider conceptually. So, i can create as many type as we want.

That analogy has not really been valid for quite a long time, as Elasticsearch has been enforcing consistent mappings for fields within an index for a long time now. Even though you could have multiple types in an index in Elasticsearch 5.x , if you had the same field used in these different types they still needed to have the same mapping.

If you necessarily want to use database analogies (I would recommend against it as it is a fundamentally different type of system), I think an Elasticsearch index is probably more like a table than a database due to these mapping constraints.

---

<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:** [July 24, 2018, 8:38am UTC](https://discuss.elastic.co/t/how-to-define-multiple-index-types-mapping-in-single-template/137370/10 "2018-07-24T08:38:47Z")

</div>

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