# Elasticsearch 6.0 Removal of mapping types - Alternatives

**URL:** <https://discuss.elastic.co/t/elasticsearch-6-0-removal-of-mapping-types-alternatives/162435>\
**Category:** Elasticsearch\
**Created:** [December 30, 2018, 6:53am UTC](https://discuss.elastic.co/t/elasticsearch-6-0-removal-of-mapping-types-alternatives/162435 "2018-12-30T06:53:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yehonatan](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@Yehonatan](https://discuss.elastic.co/u/Yehonatan)\
**Post date:** [December 30, 2018, 6:53am UTC](https://discuss.elastic.co/t/elasticsearch-6-0-removal-of-mapping-types-alternatives/162435/1 "2018-12-30T06:53:29Z")

</div>

## Background

I migrating my ES index into ES version 6. I currenly stuck because ES6 removed the using on "\_type" field.

## Old Implementation (ES2)

My software has many users (\>100K). Each user has at least one document in ES. So, the hierarchy looks like this:

```
INDEX -> TYPE -> Document
myindex-> user-123 -> document-1

```

The key point here is with this structure I can easily remove all the document of specific user.

```
DELETE /myindex/user-123

```

(Delete all the document of specific user, with a single command)

## The problem

"\_type" is no longer supported by ES6.

## Possible solution

Instead of using `_type`, use the index name as `USER-ID`. So my index will looks like:

```
"user-123" -> "static-name" -> document

```

Delete user is done by delete index (instead of delete `type` in previous implementation).

## Questions:

- My first worry is about the amount of index and performance: Having like 1M index is something that acceptable in terms of performance? don't forget I have to search on them frequently.
- Most of my users has small amount of documents stored in ES. Is that make sense to hold a shard, which should be expensive, for \< 10 documents?
- My data architecture sounds reasonable for you?

Any other tip will be welcome!  
Thanks.

---

<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:** [December 30, 2018, 8:43am UTC](https://discuss.elastic.co/t/elasticsearch-6-0-removal-of-mapping-types-alternatives/162435/2 "2018-12-30T08:43:35Z")

</div>

> [@Yehonatan](#):
>
> Most of my users has small amount of documents stored in ES. Is that make sense to hold a shard, which should be expensive, for \< 10 documents?

No, that sounds like a terrible idea. Using separate indices for small users in Elasticsearch tends to scale and perform badly as each shard comes with overhead.

Instead add a new keyword field to each document that indicates the user the document belongs to, e.g. `user_id`. You can then filter on this when querying and use [delete-by-query API](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/docs-delete-by-query.html) to delete all documents belonging to a specific user in a single command.

---

<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:** [January 27, 2019, 8:43am UTC](https://discuss.elastic.co/t/elasticsearch-6-0-removal-of-mapping-types-alternatives/162435/3 "2019-01-27T08:43:36Z")

</div>

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