# Documents with same IDs but of different types in the same index in ES6?

**URL:** <https://discuss.elastic.co/t/documents-with-same-ids-but-of-different-types-in-the-same-index-in-es6/122959>\
**Category:** Elasticsearch\
**Created:** [March 7, 2018, 8:46pm UTC](https://discuss.elastic.co/t/documents-with-same-ids-but-of-different-types-in-the-same-index-in-es6/122959 "2018-03-07T20:46:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrey\_Bakhrachev](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrey\_Bakhrachev](https://discuss.elastic.co/u/Andrey_Bakhrachev)\
**Post date:** [March 7, 2018, 8:46pm UTC](https://discuss.elastic.co/t/documents-with-same-ids-but-of-different-types-in-the-same-index-in-es6/122959/1 "2018-03-07T20:46:49Z")

</div>

Hey there,  
Sorry guys, but that mapping types removal in ES6 is quite a pain in the ass to say the least!  
As it's proposed in the docs I chose the "custom type field" option to store the different document types in the same index (creating the separate index for every document type is not an option for me), but there's a problem with that approach: documents of different types and with the same IDs overwrite each other. I tried making unique IDs artificially by concatenating document type and ID values, but no luck, because I couldn't map the ID field to anything other than integer or long type so it fails to save the documents this way. The data is coming from MySQL database, so IDs are regular integers. Am I missing something?

---

<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:** [March 7, 2018, 9:21pm UTC](https://discuss.elastic.co/t/documents-with-same-ids-but-of-different-types-in-the-same-index-in-es6/122959/2 "2018-03-07T21:21:08Z")

</div>

But how were you doing before to push your documents to the right type?

I mean instead of

```
PUT index/type1/1
{}
PUT index/type2/1
{}

```

Can't you do this?

```
PUT index/doc/type1_1
{}
PUT index/doc/type2_1
{}
```

---

<div class="post-metadata">

**Author:** ![Andrey\_Bakhrachev](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrey\_Bakhrachev](https://discuss.elastic.co/u/Andrey_Bakhrachev)\
**Post date:** [March 7, 2018, 9:28pm UTC](https://discuss.elastic.co/t/documents-with-same-ids-but-of-different-types-in-the-same-index-in-es6/122959/3 "2018-03-07T21:28:41Z")

</div>

As I said I tried this, but it didn't work, because I couldn't map ID field to the "text" type, somehow it ends up as integer or long in the mapping which is really weird.

---

<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:** [March 7, 2018, 9:44pm UTC](https://discuss.elastic.co/t/documents-with-same-ids-but-of-different-types-in-the-same-index-in-es6/122959/4 "2018-03-07T21:44:21Z")

</div>

Why? I mean what are you using to collect data from MySQL and index into elasticsearch?

---

<div class="post-metadata">

**Author:** ![Andrey\_Bakhrachev](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrey\_Bakhrachev](https://discuss.elastic.co/u/Andrey_Bakhrachev)\
**Post date:** [March 7, 2018, 10:17pm UTC](https://discuss.elastic.co/t/documents-with-same-ids-but-of-different-types-in-the-same-index-in-es6/122959/5 "2018-03-07T22:17:33Z")

</div>

It's for analytics purposes.

---

<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:** [March 7, 2018, 10:56pm UTC](https://discuss.elastic.co/t/documents-with-same-ids-but-of-different-types-in-the-same-index-in-es6/122959/6 "2018-03-07T22:56:01Z")

</div>

I said "What" and not "Why".

What is the tool/language/framework you are using to send data from your DB to elasticsearch?

---

<div class="post-metadata">

**Author:** ![Andrey\_Bakhrachev](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrey\_Bakhrachev](https://discuss.elastic.co/u/Andrey_Bakhrachev)\
**Post date:** [March 7, 2018, 11:25pm UTC](https://discuss.elastic.co/t/documents-with-same-ids-but-of-different-types-in-the-same-index-in-es6/122959/7 "2018-03-07T23:25:44Z")

</div>

Ah, right, sorry. Laravel 5.5, sleimanx2/plastic package with  
elasticsearch-php 6.0, ES 6.2.2. I haven't tried the low level way  
interaction yet though (like curl), will try that tomorrow.

---

<div class="post-metadata">

**Author:** ![Andrey\_Bakhrachev](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrey\_Bakhrachev](https://discuss.elastic.co/u/Andrey_Bakhrachev)\
**Post date:** [March 8, 2018, 1:07pm UTC](https://discuss.elastic.co/t/documents-with-same-ids-but-of-different-types-in-the-same-index-in-es6/122959/8 "2018-03-08T13:07:38Z")

</div>

Okay, it appears to be an issue in the sleimanx2/plastic package. For some reason it doesn't allow adding "text" or "keyword" field types to the mapping. Investigating further.

---

<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 5, 2018, 1:07pm UTC](https://discuss.elastic.co/t/documents-with-same-ids-but-of-different-types-in-the-same-index-in-es6/122959/9 "2018-04-05T13:07:47Z")

</div>

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