# Doubt regarding dynamic type mapping in the Index API

**URL:** <https://discuss.elastic.co/t/doubt-regarding-dynamic-type-mapping-in-the-index-api/10222>\
**Category:** Elasticsearch\
**Created:** [January 3, 2013, 6:50pm UTC](https://discuss.elastic.co/t/doubt-regarding-dynamic-type-mapping-in-the-index-api/10222 "2013-01-03T18:50:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Varun\_Thacker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varun_thacker/32/2472_2.png) [@Varun\_Thacker](https://discuss.elastic.co/u/Varun_Thacker)\
**Post date:** [January 3, 2013, 6:50pm UTC](https://discuss.elastic.co/t/doubt-regarding-dynamic-type-mapping-in-the-index-api/10222/1 "2013-01-03T18:50:11Z")

</div>

So I was going through this example on the Index API,

$ curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '{  
"user" : "kimchy",  
}'

So twitter is the name of the index and  
tweet is the type.

What does a type represent?

Also is there documentation for users to understand concepts of ES who are  
coming from a Lucene background? For example the the Parents & Children  
concept in the Index API guide documentation.

--

---

<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:** [January 3, 2013, 7:18pm UTC](https://discuss.elastic.co/t/doubt-regarding-dynamic-type-mapping-in-the-index-api/10222/2 "2013-01-03T19:18:07Z")

</div>

A type holds the mapping of your document. Within the mapping, you can define analyzers, core objects....  
An index holds the settings (basically how many shards and replica...)

Does it answer?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 3 janv. 2013 à 19:50, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com) a écrit :

So I was going through this example on the Index API,

$ curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '{  
"user" : "kimchy",  
}'

So twitter is the name of the index and  
tweet is the type.

What does a type represent?

## Also is there documentation for users to understand concepts of ES who are coming from a Lucene background? For example the the Parents & Children concept in the Index API guide documentation.

--

---

<div class="post-metadata">

**Author:** ![Varun\_Thacker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varun_thacker/32/2472_2.png) [@Varun\_Thacker](https://discuss.elastic.co/u/Varun_Thacker)\
**Post date:** [January 3, 2013, 8:13pm UTC](https://discuss.elastic.co/t/doubt-regarding-dynamic-type-mapping-in-the-index-api/10222/3 "2013-01-03T20:13:39Z")

</div>

Ah I get what type is. Similar to fieldType/field functionality in Solr I  
guess. Thanks 🙂

On Fri, Jan 4, 2013 at 12:48 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> A type holds the mapping of your document. Within the mapping, you can  
> define analyzers, core objects....  
> An index holds the settings (basically how many shards and replica...)
> 
> Does it answer?
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 3 janv. 2013 à 19:50, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com) a  
> écrit :
> 
> So I was going through this example on the Index API,
> 
> $ curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '{  
> "user" : "kimchy",  
> }'
> 
> So twitter is the name of the index and  
> tweet is the type.
> 
> What does a type represent?
> 
> Also is there documentation for users to understand concepts of ES who are  
> coming from a Lucene background? For example the the Parents & Children  
> concept in the Index API guide documentation.
> 
> --
> 
> --

--

Regards,  
Varun Thacker  
[http://www.vthacker.in/](http://www.vthacker.in/)

--

---

<div class="post-metadata">

**Author:** ![Varun\_Thacker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varun_thacker/32/2472_2.png) [@Varun\_Thacker](https://discuss.elastic.co/u/Varun_Thacker)\
**Post date:** [January 4, 2013, 6:13am UTC](https://discuss.elastic.co/t/doubt-regarding-dynamic-type-mapping-in-the-index-api/10222/4 "2013-01-04T06:13:43Z")

</div>

Actually on second thought could you give me an example where we need  
multiple type and it's mappings in a single index?

On Fri, Jan 4, 2013 at 1:43 AM, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com)wrote:

> Ah I get what type is. Similar to fieldType/field functionality in Solr I  
> guess. Thanks 🙂
> 
> On Fri, Jan 4, 2013 at 12:48 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> 
> > A type holds the mapping of your document. Within the mapping, you can  
> > define analyzers, core objects....  
> > An index holds the settings (basically how many shards and replica...)
> > 
> > Does it answer?
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 3 janv. 2013 à 19:50, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com) a  
> > écrit :
> > 
> > So I was going through this example on the Index API,
> > 
> > $ curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '{  
> > "user" : "kimchy",  
> > }'
> > 
> > So twitter is the name of the index and  
> > tweet is the type.
> > 
> > What does a type represent?
> > 
> > Also is there documentation for users to understand concepts of ES who  
> > are coming from a Lucene background? For example the the Parents & Children  
> > concept in the Index API guide documentation.
> > 
> > --
> > 
> > --
> 
> --
> 
> Regards,  
> Varun Thacker  
> [http://www.vthacker.in/](http://www.vthacker.in/)

--

Regards,  
Varun Thacker  
[http://www.vthacker.in/](http://www.vthacker.in/)

--

---

<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:** [January 4, 2013, 6:34am UTC](https://discuss.elastic.co/t/doubt-regarding-dynamic-type-mapping-in-the-index-api/10222/5 "2013-01-04T06:34:01Z")

</div>

If you want to index Tweets from Twitter (search for tweets) and if you want to index Twitter users (search for users), you can create a twitter index with 2 types: tweet and user.  
A tweet doesn't have the same properties as a user.

If you want to index also WallPosts from Facebook and Facebook users, you can create a facebook index with two types: post and user.

Make sense?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 4 janv. 2013 à 07:13, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com) a écrit :

Actually on second thought could you give me an example where we need multiple type and it's mappings in a single index?

On Fri, Jan 4, 2013 at 1:43 AM, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com) wrote:

> Ah I get what type is. Similar to fieldType/field functionality in Solr I guess. Thanks 🙂
> 
> On Fri, Jan 4, 2013 at 12:48 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> 
> > A type holds the mapping of your document. Within the mapping, you can define analyzers, core objects....  
> > An index holds the settings (basically how many shards and replica...)
> > 
> > Does it answer?
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 3 janv. 2013 à 19:50, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com) a écrit :
> > 
> > So I was going through this example on the Index API,
> > 
> > $ curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '{  
> > "user" : "kimchy",  
> > }'
> > 
> > So twitter is the name of the index and  
> > tweet is the type.
> > 
> > What does a type represent?
> > 
> > ## Also is there documentation for users to understand concepts of ES who are coming from a Lucene background? For example the the Parents & Children concept in the Index API guide documentation.
> > 
> > --
> 
> --
> 
> Regards,  
> Varun Thacker  
> [http://www.vthacker.in/](http://www.vthacker.in/)

--

## Regards, Varun Thacker [http://www.vthacker.in/](http://www.vthacker.in/)

--

---

<div class="post-metadata">

**Author:** ![Varun\_Thacker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varun_thacker/32/2472_2.png) [@Varun\_Thacker](https://discuss.elastic.co/u/Varun_Thacker)\
**Post date:** [January 4, 2013, 6:52am UTC](https://discuss.elastic.co/t/doubt-regarding-dynamic-type-mapping-in-the-index-api/10222/6 "2013-01-04T06:52:11Z")

</div>

I do understand your point of view for having a type, but according to me  
indexing tweets and indexing twitter users should be two different indexes  
itself thus we could have type mappings as part of the index properties  
removing the need of a type.

Would you consider this approach as wrong?

On Fri, Jan 4, 2013 at 12:04 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> If you want to index Tweets from Twitter (search for tweets) and if you  
> want to index Twitter users (search for users), you can create a twitter  
> index with 2 types: tweet and user.  
> A tweet doesn't have the same properties as a user.
> 
> If you want to index also WallPosts from Facebook and Facebook users, you  
> can create a facebook index with two types: post and user.
> 
> Make sense?
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 4 janv. 2013 à 07:13, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com) a  
> écrit :
> 
> Actually on second thought could you give me an example where we need  
> multiple type and it's mappings in a single index?
> 
> On Fri, Jan 4, 2013 at 1:43 AM, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com)wrote:
> 
> > Ah I get what type is. Similar to fieldType/field functionality in Solr I  
> > guess. Thanks 🙂
> > 
> > On Fri, Jan 4, 2013 at 12:48 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> > 
> > > A type holds the mapping of your document. Within the mapping, you can  
> > > define analyzers, core objects....  
> > > An index holds the settings (basically how many shards and replica...)
> > > 
> > > Does it answer?
> > > 
> > > --  
> > > David 😉  
> > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > 
> > > Le 3 janv. 2013 à 19:50, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com) a  
> > > écrit :
> > > 
> > > So I was going through this example on the Index API,
> > > 
> > > $ curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '{  
> > > "user" : "kimchy",  
> > > }'
> > > 
> > > So twitter is the name of the index and  
> > > tweet is the type.
> > > 
> > > What does a type represent?
> > > 
> > > Also is there documentation for users to understand concepts of ES who  
> > > are coming from a Lucene background? For example the the Parents & Children  
> > > concept in the Index API guide documentation.
> > > 
> > > --
> > > 
> > > --
> > 
> > --
> > 
> > Regards,  
> > Varun Thacker  
> > [http://www.vthacker.in/](http://www.vthacker.in/)
> 
> --
> 
> Regards,  
> Varun Thacker  
> [http://www.vthacker.in/](http://www.vthacker.in/)
> 
> --
> 
> --

--

Regards,  
Varun Thacker  
[http://www.vthacker.in/](http://www.vthacker.in/)

--

---

<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:** [January 4, 2013, 7:01am UTC](https://discuss.elastic.co/t/doubt-regarding-dynamic-type-mapping-in-the-index-api/10222/7 "2013-01-04T07:01:44Z")

</div>

In fact, you can do what you want with ES.  
The way I see it is that I prefer store objects that have a common meaning (or source or functionnal sense - I don't know what is the right term) in the same index.

Index are created to define shards and to allow horizontal scaling. You have to know that each shard of an index is a Lucene instance. If you create too much shards on the same node, you will probably hit the "too many open files" issue.

Think index as technical structure. Think type as business docs...

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 4 janv. 2013 à 07:52, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com) a écrit :

I do understand your point of view for having a type, but according to me indexing tweets and indexing twitter users should be two different indexes itself thus we could have type mappings as part of the index properties removing the need of a type.

Would you consider this approach as wrong?

On Fri, Jan 4, 2013 at 12:04 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> If you want to index Tweets from Twitter (search for tweets) and if you want to index Twitter users (search for users), you can create a twitter index with 2 types: tweet and user.  
> A tweet doesn't have the same properties as a user.
> 
> If you want to index also WallPosts from Facebook and Facebook users, you can create a facebook index with two types: post and user.
> 
> Make sense?
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 4 janv. 2013 à 07:13, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com) a écrit :
> 
> Actually on second thought could you give me an example where we need multiple type and it's mappings in a single index?
> 
> On Fri, Jan 4, 2013 at 1:43 AM, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com) wrote:
> 
> > Ah I get what type is. Similar to fieldType/field functionality in Solr I guess. Thanks 🙂
> > 
> > On Fri, Jan 4, 2013 at 12:48 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> > 
> > > A type holds the mapping of your document. Within the mapping, you can define analyzers, core objects....  
> > > An index holds the settings (basically how many shards and replica...)
> > > 
> > > Does it answer?
> > > 
> > > --  
> > > David 😉  
> > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > 
> > > Le 3 janv. 2013 à 19:50, Varun Thacker [varunthacker1989@gmail.com](mailto:varunthacker1989@gmail.com) a écrit :
> > > 
> > > So I was going through this example on the Index API,
> > > 
> > > $ curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '{  
> > > "user" : "kimchy",  
> > > }'
> > > 
> > > So twitter is the name of the index and  
> > > tweet is the type.
> > > 
> > > What does a type represent?
> > > 
> > > ## Also is there documentation for users to understand concepts of ES who are coming from a Lucene background? For example the the Parents & Children concept in the Index API guide documentation.
> > > 
> > > --
> > 
> > --
> > 
> > Regards,  
> > Varun Thacker  
> > [http://www.vthacker.in/](http://www.vthacker.in/)
> 
> --
> 
> ## Regards, Varun Thacker [http://www.vthacker.in/](http://www.vthacker.in/)
> 
> --

--

## Regards, Varun Thacker [http://www.vthacker.in/](http://www.vthacker.in/)

--

---

<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, 2:57am UTC](https://discuss.elastic.co/t/doubt-regarding-dynamic-type-mapping-in-the-index-api/10222/8 "2017-07-06T02:57:50Z")

</div>


