# How to create sub-indices inside indices

**URL:** <https://discuss.elastic.co/t/how-to-create-sub-indices-inside-indices/171725>\
**Category:** Elasticsearch\
**Created:** [March 11, 2019, 10:20am UTC](https://discuss.elastic.co/t/how-to-create-sub-indices-inside-indices/171725 "2019-03-11T10:20:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![soumrock123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/soumrock123/32/41473_2.png) [@soumrock123](https://discuss.elastic.co/u/soumrock123)\
**Post date:** [March 11, 2019, 10:20am UTC](https://discuss.elastic.co/t/how-to-create-sub-indices-inside-indices/171725/1 "2019-03-11T10:20:49Z")

</div>

I have currently around 200 customer databases under one ES node and for each database, I am running 10 different queries to assess performance. For that I have 200\*10 indices now, but that does not look good. I plan to create one index per customer and create sub indices under each for each query result. Is that feasible?

---

<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 11, 2019, 10:49am UTC](https://discuss.elastic.co/t/how-to-create-sub-indices-inside-indices/171725/2 "2019-03-11T10:49:52Z")

</div>

Sub indices does not exist.  
But you can put all data within the same index and just filter data by user id.

---

<div class="post-metadata">

**Author:** ![soumrock123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/soumrock123/32/41473_2.png) [@soumrock123](https://discuss.elastic.co/u/soumrock123)\
**Post date:** [March 11, 2019, 11:00am UTC](https://discuss.elastic.co/t/how-to-create-sub-indices-inside-indices/171725/3 "2019-03-11T11:00:55Z")

</div>

So can I create one index per customer and filter the queries by type ID or query ID? Because the query results yield similar data format from each database and I want to compare them in Kibana

---

<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 11, 2019, 11:18am UTC](https://discuss.elastic.co/t/how-to-create-sub-indices-inside-indices/171725/4 "2019-03-11T11:18:15Z")

</div>

No you create one index for all. Then filter by customer.  
You can also use filtered aliases and create one alias per customer then.

---

<div class="post-metadata">

**Author:** ![soumrock123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/soumrock123/32/41473_2.png) [@soumrock123](https://discuss.elastic.co/u/soumrock123)\
**Post date:** [March 21, 2019, 11:12am UTC](https://discuss.elastic.co/t/how-to-create-sub-indices-inside-indices/171725/5 "2019-03-21T11:12:38Z")

</div>

Hello again, I just noticed something today that Kibana is not showing more than 100 indices in the "Discover Indices" tab although running this query  
GET \_search  
{  
"query": {  
"match\_all": {}  
}  
}  
displays more.  
Since you advised me to create a single index, I have 2 questions -

1. Is there any restriction on the number of types too? E.g if I have 500 types within 1 large index, will Kibana display only 100?
2. Will Elastic, in the future, impose a restriction on the number of indices created and/or increase the default size of each one?  
Sorry for bugging you but these info will be important to me for designing the node.

---

<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:** [March 21, 2019, 11:58am UTC](https://discuss.elastic.co/t/how-to-create-sub-indices-inside-indices/171725/6 "2019-03-21T11:58:45Z")

</div>

> [@soumrock123](#):
>
> Is there any restriction on the number of types too? E.g if I have 500 types within 1 large index, will Kibana display only 100?

In Elasticsearch 6.0 onwards only a single type per index is allowed. You can however add a field to your documents indicating type and use this for filtering as long as there are no mapping conflicts.

> [@soumrock123](#):
>
> Will Elastic, in the future, impose a restriction on the number of indices created and/or increase the default size of each one?

Having lots of small indices and shards is inefficient as there is overhead for each shard. Having an index per customer works for few users but does not scale well. From Elasticsearch 7.x i believe there will be a soft limit for the number of shards per node.

---

<div class="post-metadata">

**Author:** ![soumrock123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/soumrock123/32/41473_2.png) [@soumrock123](https://discuss.elastic.co/u/soumrock123)\
**Post date:** [March 21, 2019, 1:56pm UTC](https://discuss.elastic.co/t/how-to-create-sub-indices-inside-indices/171725/7 "2019-03-21T13:56:11Z")

</div>

Thanks for the explanation. But the procedure is becoming quite confusing.  
Firstly the "document\_type" field has been deprecated and now I have learnt today that only a single type per index is allowed. My question is what is the purpose of "type" then?  
So can I modify the number of indices or types shown by Kibana or that is restricted too? Creating index patterns and segregating fields in Kibana gets quite confusing.

---

<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 18, 2019, 2:03pm UTC](https://discuss.elastic.co/t/how-to-create-sub-indices-inside-indices/171725/8 "2019-04-18T14:03:46Z")

</div>

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