# How to create many small separate indices

**URL:** <https://discuss.elastic.co/t/how-to-create-many-small-separate-indices/326459>\
**Category:** Elasticsearch\
**Created:** [February 24, 2023, 5:25pm UTC](https://discuss.elastic.co/t/how-to-create-many-small-separate-indices/326459 "2023-02-24T17:25:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim28](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim28/32/117738_2.png) [@tim28](https://discuss.elastic.co/u/tim28)\
**Post date:** [February 24, 2023, 5:25pm UTC](https://discuss.elastic.co/t/how-to-create-many-small-separate-indices/326459/1 "2023-02-24T17:25:59Z")

</div>

Hi!

I want to create many (~10k) indices each having a couple of hundred documents. I have read in other places that that's discouraged as it creates a shard per index which is a lot of overhead. However, I have the requirement that the indexing of the documents is separate. I.e. I do not want the text statistics of a document belonging to index A influences those in index B. Any ideas on how to solve this?

I was thinking to have a few indices, but with many mappings where each mapping would hold only the documents that should be indexed together. Would that work?

---

<div class="post-metadata">

**Author:** ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)\
**Post date:** [February 24, 2023, 5:34pm UTC](https://discuss.elastic.co/t/how-to-create-many-small-separate-indices/326459/2 "2023-02-24T17:34:56Z")

</div>

You can have one index with multiple groups of fields to organize the mapping  
Example

| group | field |
| --- | --- |
| doc\_type\_1 | doc\_type1\_field1 |
| | doc\_type1\_field2 |
| | doc\_type1\_field3 |
| | doc\_type1\_field4 |
| | doc\_type1\_field5 |
| | doc\_type1\_field6 |
| | doc\_type1\_field7 |
| | |
| | |
| doc\_type\_2 | doc\_type2\_field1 |
| | doc\_type2\_field2 |
| | doc\_type2\_field3 |
| | doc\_type2\_field4 |
| | doc\_type2\_field5 |
| | doc\_type2\_field6 |
| | doc\_type2\_field7 |

---

<div class="post-metadata">

**Author:** ![tim28](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim28/32/117738_2.png) [@tim28](https://discuss.elastic.co/u/tim28)\
**Post date:** [February 24, 2023, 6:09pm UTC](https://discuss.elastic.co/t/how-to-create-many-small-separate-indices/326459/3 "2023-02-24T18:09:07Z")

</div>

Is it also possible to solve it with aliases? Ie have many aliases that point to the same index? Would that also respect the "separate indexing"? That is at least my understanding what was suggested in the form [here](https://discuss.elastic.co/t/how-to-handle-lots-of-small-indices/272063/2)

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [February 24, 2023, 6:15pm UTC](https://discuss.elastic.co/t/how-to-create-many-small-separate-indices/326459/4 "2023-02-24T18:15:31Z")

</div>

many alias is not many index. not that many overhead compare to 10k index.

one node in system has limit of 1000 active shard limit. you can have 2000 if you want but then node will behave differently can't tell how.

one index has one mapping can't have multiple mapping.  
mapping is basically telling you what kind of field type you have in that index, text,keyword,int,bool etc..

if you post some example record then it will give more idea on how to organize. Now a days there are many different way same thing can be done.

---

<div class="post-metadata">

**Author:** ![tim28](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim28/32/117738_2.png) [@tim28](https://discuss.elastic.co/u/tim28)\
**Post date:** [February 24, 2023, 7:23pm UTC](https://discuss.elastic.co/t/how-to-create-many-small-separate-indices/326459/5 "2023-02-24T19:23:21Z")

</div>

I have actually just tried creating a single index with many aliases and a filter per alias. However, that does not seem to respect analyzing the documents "per alias" separately. At least when I do a search with /\_explain, it tells me some terms were found in 1000s of documents in the index (but for that alias, there are only ~100 documents).

---

<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:** [February 24, 2023, 7:27pm UTC](https://discuss.elastic.co/t/how-to-create-many-small-separate-indices/326459/6 "2023-02-24T19:27:48Z")

</div>

Aliases can only offer filtering and does as you correctly pointed out not affect relevancy. Having lots of aliases could in inself be an issue anyway. I suspect grouping data as Yassine suggested might be a good compromise.

---

<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 24, 2023, 7:28pm UTC](https://discuss.elastic.co/t/how-to-create-many-small-separate-indices/326459/7 "2023-03-24T19:28:08Z")

</div>

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