# Purpose of types under one index

**URL:** <https://discuss.elastic.co/t/purpose-of-types-under-one-index/21239>\
**Category:** Elasticsearch\
**Created:** [December 12, 2014, 7:43pm UTC](https://discuss.elastic.co/t/purpose-of-types-under-one-index/21239 "2014-12-12T19:43:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fye](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@fye](https://discuss.elastic.co/u/fye)\
**Post date:** [December 12, 2014, 7:43pm UTC](https://discuss.elastic.co/t/purpose-of-types-under-one-index/21239/1 "2014-12-12T19:43:15Z")

</div>

Gurus,

would you shed some lights for a newbie. What is the top benefits of adding  
the level of 'type' beyond one level Lucene index? What are the top use  
cases that requires multiple types (schemas) within one index?

thanks!

--  
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/e99e4a35-4ee9-42b1-b619-63225cd315f5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e99e4a35-4ee9-42b1-b619-63225cd315f5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [December 12, 2014, 8:00pm UTC](https://discuss.elastic.co/t/purpose-of-types-under-one-index/21239/2 "2014-12-12T20:00:48Z")

</div>

Sometimes, people have to search accross multiple enterprise applications.  
Each application write in a given index and can manage many type of documents.

So it's more a convenient way to separate things. Have one index per type in some cases could be strange if you indexed only a few docs.

That said, if you can have one single type per index, I think it's better. You will avoid collisions between fields within the same index. I mean a field X can belong to type1 and another field X to type2. But you could imagine different rules for each (one is a String, the other a Date).  
Here you can start having some troubles.

My 2 cents.

David

> Le 12 déc. 2014 à 20:43, fye [fyemaple@gmail.com](mailto:fyemaple@gmail.com) a écrit :
> 
> Gurus,
> 
> would you shed some lights for a newbie. What is the top benefits of adding the level of 'type' beyond one level Lucene index? What are the top use cases that requires multiple types (schemas) within one index?
> 
> ## thanks!
> 
> 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/e99e4a35-4ee9-42b1-b619-63225cd315f5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e99e4a35-4ee9-42b1-b619-63225cd315f5%40googlegroups.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/60AEC1A7-487D-4465-8C01-E1E9BFB64F41%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/60AEC1A7-487D-4465-8C01-E1E9BFB64F41%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![fye](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@fye](https://discuss.elastic.co/u/fye)\
**Post date:** [December 15, 2014, 3:40pm UTC](https://discuss.elastic.co/t/purpose-of-types-under-one-index/21239/3 "2014-12-15T15:40:32Z")

</div>

Appreciate it David!

Would love to hear more opinions form others. So far I have not seen enough  
benefits (other than avoiding to have too many indexes) to justify the  
complexity that adding the type level brings in.

feng

On Friday, December 12, 2014 3:00:58 PM UTC-5, David Pilato wrote:

> Sometimes, people have to search accross multiple enterprise applications.  
> Each application write in a given index and can manage many type of  
> documents.
> 
> So it's more a convenient way to separate things. Have one index per type  
> in some cases could be strange if you indexed only a few docs.
> 
> That said, if you can have one single type per index, I think it's better.  
> You will avoid collisions between fields within the same index. I mean a  
> field X can belong to type1 and another field X to type2. But you could  
> imagine different rules for each (one is a String, the other a Date).  
> Here you can start having some troubles.
> 
> My 2 cents.
> 
> David
> 
> Le 12 déc. 2014 à 20:43, fye \<[fyem...@gmail.com](mailto:fyem...@gmail.com) \<javascript:\>\> a écrit :
> 
> Gurus,
> 
> would you shed some lights for a newbie. What is the top benefits of  
> adding the level of 'type' beyond one level Lucene index? What are the top  
> use cases that requires multiple types (schemas) within one index?
> 
> thanks!
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/e99e4a35-4ee9-42b1-b619-63225cd315f5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e99e4a35-4ee9-42b1-b619-63225cd315f5%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/e99e4a35-4ee9-42b1-b619-63225cd315f5%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/e99e4a35-4ee9-42b1-b619-63225cd315f5%40googlegroups.com?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/d99b0d8e-010f-401c-8514-23b3e5f219d1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d99b0d8e-010f-401c-8514-23b3e5f219d1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [December 15, 2014, 7:30pm UTC](https://discuss.elastic.co/t/purpose-of-types-under-one-index/21239/4 "2014-12-15T19:30:00Z")

</div>

Here are my 2 ¢

The type feature of an index was invented to allow cross-search over  
document types without adding another whole Lucene index.

Imagine a library catalog. If you have books, you have fields like title,  
author, publisher, subject, extent, identifier etc. So, you can create an  
index "catalog" with a basic type "book". Then, you can add a type  
"serials", which have a slightly changed mapping, consider ISSN, numbering,  
issues/volumes etc. Then, you can add a type "CD", e.g. with field  
length/duration of an audio book, or digital format information. And so on.  
As a result, you can search with a single query in an index over types with  
different document sizes, and this saves space regarding \_source.

The advantage of types is that you can create a basic mapping and extend  
this dynamically in the future without changing the docs that are already  
indexed. You do not even have to know the final set of types that may have  
to be added later when creating the index and this makes it very flexible.

The type feature is good for all use cases where you have to store document  
types in a single collection, which might share fields with other types,  
and you want to save the overhead of extra shards or index aliasing. The  
\_uid field (an internal field) provides special caching performance  
features for filtering the types in an index.

Jörg

On Mon, Dec 15, 2014 at 4:40 PM, fye [fyemaple@gmail.com](mailto:fyemaple@gmail.com) wrote:

> Appreciate it David!
> 
> Would love to hear more opinions form others. So far I have not seen  
> enough benefits (other than avoiding to have too many indexes) to justify  
> the complexity that adding the type level brings in.
> 
> feng
> 
> On Friday, December 12, 2014 3:00:58 PM UTC-5, David Pilato wrote:
> 
> > Sometimes, people have to search accross multiple enterprise applications.  
> > Each application write in a given index and can manage many type of  
> > documents.
> > 
> > So it's more a convenient way to separate things. Have one index per type  
> > in some cases could be strange if you indexed only a few docs.
> > 
> > That said, if you can have one single type per index, I think it's  
> > better. You will avoid collisions between fields within the same index. I  
> > mean a field X can belong to type1 and another field X to type2. But you  
> > could imagine different rules for each (one is a String, the other a Date).  
> > Here you can start having some troubles.
> > 
> > My 2 cents.
> > 
> > David
> > 
> > Le 12 déc. 2014 à 20:43, fye [fyem...@gmail.com](mailto:fyem...@gmail.com) a écrit :
> > 
> > Gurus,
> > 
> > would you shed some lights for a newbie. What is the top benefits of  
> > adding the level of 'type' beyond one level Lucene index? What are the top  
> > use cases that requires multiple types (schemas) within one index?
> > 
> > thanks!
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > msgid/elasticsearch/e99e4a35-4ee9-42b1-b619-63225cd315f5%  
> > [40googlegroups.com](http://40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/e99e4a35-4ee9-42b1-b619-63225cd315f5%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/e99e4a35-4ee9-42b1-b619-63225cd315f5%40googlegroups.com?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/d99b0d8e-010f-401c-8514-23b3e5f219d1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d99b0d8e-010f-401c-8514-23b3e5f219d1%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/d99b0d8e-010f-401c-8514-23b3e5f219d1%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/d99b0d8e-010f-401c-8514-23b3e5f219d1%40googlegroups.com?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/CAKdsXoFRA1z9xFmjvCH-99Hqg-\_3CkrYNLbmStUD8KTuW8RR%3Dg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFRA1z9xFmjvCH-99Hqg-_3CkrYNLbmStUD8KTuW8RR%3Dg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:43am UTC](https://discuss.elastic.co/t/purpose-of-types-under-one-index/21239/5 "2017-07-06T00:43:40Z")

</div>


