# Are documents of different types indexed via one index?

**URL:** <https://discuss.elastic.co/t/are-documents-of-different-types-indexed-via-one-index/22784>\
**Category:** Elasticsearch\
**Created:** [March 20, 2015, 8:08pm UTC](https://discuss.elastic.co/t/are-documents-of-different-types-indexed-via-one-index/22784 "2015-03-20T20:08:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![11181](https://avatars.discourse-cdn.com/v4/letter/1/34f0e0/32.png) [@11181](https://discuss.elastic.co/u/11181)\
**Post date:** [March 20, 2015, 8:08pm UTC](https://discuss.elastic.co/t/are-documents-of-different-types-indexed-via-one-index/22784/1 "2015-03-20T20:08:38Z")

</div>

From ES document I understood that index is like database and document type is like table. Every table has its own indexes.

Let's suppose we have one ES index with two document types (posts and book) and we have 1000000000 posts and 30 books. If I search for some text expression in ONLY books will my query be very fast or slow? By other words - documents of different types are indexed via one index or for every document type separate index is created?

--  
Александр Свиридов

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1426882118.273423714%40f319.i.mail.ru](https://groups.google.com/d/msgid/elasticsearch/1426882118.273423714%40f319.i.mail.ru).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 20, 2015, 9:19pm UTC](https://discuss.elastic.co/t/are-documents-of-different-types-indexed-via-one-index/22784/2 "2015-03-20T21:19:04Z")

</div>

You can mix types in a single index, but we recommend you separate them out.

Obviously a search against 30 docs is a lot faster than one against 1  
billion.

On 20 March 2015 at 13:08, Александр Свиридов [ooo\_saturn7@mail.ru](mailto:ooo_saturn7@mail.ru) wrote:

> From ES document I understood that index is like database and document  
> type is like table. Every table has its own indexes.
> 
> Let's suppose we have one ES index with two document types (posts and  
> book) and we have 1000000000 posts and 30 books. If I search for some text  
> expression in ONLY books will my query be very fast or slow? By other  
> words - documents of different types are indexed via one index or for every  
> document type separate index is created?
> 
> --  
> Александр Свиридов
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1426882118.273423714%40f319.i.mail.ru](https://groups.google.com/d/msgid/elasticsearch/1426882118.273423714%40f319.i.mail.ru)  
> [https://groups.google.com/d/msgid/elasticsearch/1426882118.273423714%40f319.i.mail.ru?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/1426882118.273423714%40f319.i.mail.ru?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAEYi1X9JTafPbhBBeL4GLj3Bs\_wenZsRP5DnutQVu0gU%3DdypLQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAEYi1X9JTafPbhBBeL4GLj3Bs_wenZsRP5DnutQVu0gU%3DdypLQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![11181](https://avatars.discourse-cdn.com/v4/letter/1/34f0e0/32.png) [@11181](https://discuss.elastic.co/u/11181)\
**Post date:** [March 20, 2015, 9:37pm UTC](https://discuss.elastic.co/t/are-documents-of-different-types-indexed-via-one-index/22784/3 "2015-03-20T21:37:04Z")

</div>

So, as I understand you ritgh all documents of all types in one index indexed together. Not as in databases - one table (ome type) - one index.

Пятница, 20 марта 2015, 14:19 -07:00 от Mark Walkom [markwalkom@gmail.com](mailto:markwalkom@gmail.com):

> You can mix types in a single index, but we recommend you separate them out.
> 
> Obviously a search against 30 docs is a lot faster than one against 1 billion.
> 
> On 20 March 2015 at 13:08, Александр Свиридов \< [ooo\_saturn7@mail.ru](mailto:ooo_saturn7@mail.ru) \> wrote:
> 
> > From ES document I understood that index is like database and document type is like table. Every table has its own indexes.
> > 
> > Let's suppose we have one ES index with two document types (posts and book) and we have 1000000000 posts and 30 books. If I search for some text expression in ONLY books will my query be very fast or slow? By other words - documents of different types are indexed via one index or for every document type separate index is created?
> > 
> > ## -- Александр Свиридов
> > 
> > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) .  
> > To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1426882118.273423714%40f319.i.mail.ru](https://groups.google.com/d/msgid/elasticsearch/1426882118.273423714%40f319.i.mail.ru) .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) .
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) .  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAEYi1X9JTafPbhBBeL4GLj3Bs\_wenZsRP5DnutQVu0gU%3DdypLQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAEYi1X9JTafPbhBBeL4GLj3Bs_wenZsRP5DnutQVu0gU%3DdypLQ%40mail.gmail.com) .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) .

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1426887424.631597516%40f411.i.mail.ru](https://groups.google.com/d/msgid/elasticsearch/1426887424.631597516%40f411.i.mail.ru).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![unknownunknown](https://avatars.discourse-cdn.com/v4/letter/u/4da419/32.png) [@unknownunknown](https://discuss.elastic.co/u/unknownunknown)\
**Post date:** [December 23, 2015, 1:56pm UTC](https://discuss.elastic.co/t/are-documents-of-different-types-indexed-via-one-index/22784/4 "2015-12-23T13:56:18Z")

</div>

> [@warkolm](#):
>
> You can mix types in a single index, but we recommend you separate them out.

Could you please elaborate on this, or point towards a resource that explains this better? Thanks.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 23, 2015, 2:51pm UTC](https://discuss.elastic.co/t/are-documents-of-different-types-indexed-via-one-index/22784/5 "2015-12-23T14:51:07Z")

</div>

> [@unknownunknown](#):
>
> Could you please elaborate on this, or point towards a resource that explains this better?

How about [Index vs. Type | Elastic Blog](https://www.elastic.co/blog/index-vs-type) ?

---

<div class="post-metadata">

**Author:** ![unknownunknown](https://avatars.discourse-cdn.com/v4/letter/u/4da419/32.png) [@unknownunknown](https://discuss.elastic.co/u/unknownunknown)\
**Post date:** [December 23, 2015, 6:05pm UTC](https://discuss.elastic.co/t/are-documents-of-different-types-indexed-via-one-index/22784/6 "2015-12-23T18:05:53Z")

</div>

Thanks, I find this to be useful context. However, I don't find a direct explanation for the reasons why separate indices are preferred over a single index with multiple types.

There are some data modeling implications that are mentioned (field name, storage of sparse fields, scoring). This to me suggests there may be times where the index + types model is useful (and your cited article says as much).

My reading of the above statement recommends that multiple types not be present in an index, suggesting that the index + types model may not be so useful, more or less in the form: "Don't mix types in a single index because $badthing."

Thanks again for your response.

---

<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:** [July 5, 2017, 11:29pm UTC](https://discuss.elastic.co/t/are-documents-of-different-types-indexed-via-one-index/22784/7 "2017-07-05T23:29:01Z")

</div>


