# Trying to decide to use indices or types

**URL:** <https://discuss.elastic.co/t/trying-to-decide-to-use-indices-or-types/121771>\
**Category:** Elasticsearch\
**Created:** [February 28, 2018, 3:41am UTC](https://discuss.elastic.co/t/trying-to-decide-to-use-indices-or-types/121771 "2018-02-28T03:41:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dr\_dob](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dr\_dob](https://discuss.elastic.co/u/dr_dob)\
**Post date:** [February 28, 2018, 3:41am UTC](https://discuss.elastic.co/t/trying-to-decide-to-use-indices-or-types/121771/1 "2018-02-28T03:41:33Z")

</div>

Hi

Use case: I'm trying to separate my documents for each client. As in, one client may only be interested in documents that only have \_\_\_ value for \_\_\_ field. Currently, I have a main index with all documents, and then reindexing documents that the client is interested in to their own index.

So, all documents have the same mapping. Just want to separate them.

Should I be creating types for each user instead.

I read this:  
"If you have many documents for each type, then the overhead of Lucene indices will be easily amortized so you can safely use indices, with fewer shards than the default of 5 if necessary"

but it still isnt clear

---

<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:** [February 28, 2018, 12:22pm UTC](https://discuss.elastic.co/t/trying-to-decide-to-use-indices-or-types/121771/2 "2018-02-28T12:22:58Z")

</div>

I guess you have in your index a field like clientId or something.

You could use filtered aliases instead of reindexing IMHO.

---

<div class="post-metadata">

**Author:** ![dr\_dob](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dr\_dob](https://discuss.elastic.co/u/dr_dob)\
**Post date:** [February 28, 2018, 7:43pm UTC](https://discuss.elastic.co/t/trying-to-decide-to-use-indices-or-types/121771/3 "2018-02-28T19:43:33Z")

</div>

We currently don't. I've thought about this though:

Create a field clientIDs that contains a set of client IDs. Then, for the dashboards that we are providing clients, filter by client ID's. But, then, for the API we are providing our clients, how would you recommend filtering aliases?

Very helpful, thanks

---

<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:** [February 28, 2018, 8:20pm UTC](https://discuss.elastic.co/t/trying-to-decide-to-use-indices-or-types/121771/4 "2018-02-28T20:20:40Z")

</div>

> how would you recommend filtering aliases?

Create a clientA alias which points to your indices. And filter this alias with a term query on the clientId field.

More details at [Index Aliases | Elasticsearch Reference [6.2] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/indices-aliases.html#filtered)

---

<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:** [March 28, 2018, 8:20pm UTC](https://discuss.elastic.co/t/trying-to-decide-to-use-indices-or-types/121771/5 "2018-03-28T20:20:49Z")

</div>

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