# Unique index for each user

**URL:** https://discuss.elastic.co/t/unique-index-for-each-user/231820
**Category:** Elasticsearch
**Created:** [May 9, 2020, 7:23am UTC](https://discuss.elastic.co/t/unique-index-for-each-user/231820 "2020-05-09T07:23:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![JavaDeveloper](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javadeveloper/32/67144_2.png) [@JavaDeveloper](https://discuss.elastic.co/u/JavaDeveloper)
#### Post date: [May 9, 2020, 7:23am UTC](https://discuss.elastic.co/t/unique-index-for-each-user/231820/1 "2020-05-09T07:23:21Z")

</div>

Hi everyone.  
I'm sending my application's logs to logstash as json and I want to save them in elasticsearch by different indices.  
In fact, I want to save logs of each user in a unique index that is equal to user key in the incoming json document. Because I want to provide different services to different users.  
For example:

- document storage time and also services for users can vary.
- log content of each user may increase and I intend to increase the query speed by separating the indices.

Therefore:  
Q1: Is it a good idea to separate each user's index?  
Q2: How can I do it in logstash output config file?

---

<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: [May 9, 2020, 7:37am UTC](https://discuss.elastic.co/t/unique-index-for-each-user/231820/2 "2020-05-09T07:37:27Z")

</div>

Having lots of small indices and shards is very inefficient and does not d ale well. Separating indices per user can work for relatively small number of users though. If you however have lots of small users it is generally better to have them share indices and filter the queries.

How many users do you expect to need to support?

---

<div class="post-metadata">

### Author: ![JavaDeveloper](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javadeveloper/32/67144_2.png) [@JavaDeveloper](https://discuss.elastic.co/u/JavaDeveloper)
#### Post date: [May 9, 2020, 8:05am UTC](https://discuss.elastic.co/t/unique-index-for-each-user/231820/3 "2020-05-09T08:05:03Z")

</div>

About 100,000 users. So do you recommend have same index for all users?

---

<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: [May 9, 2020, 8:07am UTC](https://discuss.elastic.co/t/unique-index-for-each-user/231820/4 "2020-05-09T08:07:18Z")

</div>

With that amount of users you need to at least group them and could possibly benefit from using routing.

---

<div class="post-metadata">

### Author: ![JavaDeveloper](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javadeveloper/32/67144_2.png) [@JavaDeveloper](https://discuss.elastic.co/u/JavaDeveloper)
#### Post date: [May 9, 2020, 8:12am UTC](https://discuss.elastic.co/t/unique-index-for-each-user/231820/5 "2020-05-09T08:12:29Z")

</div>

@Christian_Dahlqvist  
Thank you.

---

<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: [June 6, 2020, 8:12am UTC](https://discuss.elastic.co/t/unique-index-for-each-user/231820/6 "2020-06-06T08:12:31Z")

</div>

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