# Index and Mapping Creation

**URL:** <https://discuss.elastic.co/t/index-and-mapping-creation/5141>\
**Category:** Elasticsearch\
**Created:** [August 12, 2011, 4:27pm UTC](https://discuss.elastic.co/t/index-and-mapping-creation/5141 "2011-08-12T16:27:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Cook](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@James\_Cook](https://discuss.elastic.co/u/James_Cook)\
**Post date:** [August 12, 2011, 4:27pm UTC](https://discuss.elastic.co/t/index-and-mapping-creation/5141/1 "2011-08-12T16:27:44Z")

</div>

_Background_

We embed elasticsearch into our web application, and then let Amazon EC2  
control the startup or teardown of our server instances based on load  
metrics. The exact same web app is used across all instances, therefore each  
new instance brings a new elasticsearch node into existence.

I am trying to bulletproof some scenarios, and just want to ask what the  
best practice might be for some of these situations.

_Programmatic Index/Mapping Creation_

We are currently defining our index settings in an elasticsearch.properties  
file that we feed to our embedded ES node when we start it up. We store our  
mapping files in a location that ES can find and the first time a document  
is indexed by ES, the mapping files are read in and properly applied.

One problem, is the mapping files are not automatically loaded if the first  
request to ES is a query. Is there a setting that can tell ES to load the  
mapping files when the node is created?

At the moment we use the same index configuration across all of our  
indicies. If we wanted to specify different index configurations per index,  
would we have to resort to a programmatic creation of the indicies via an  
API call?

If we switch to programmatic creation of index and mappings, am I right to  
assume that this only has to happen on the first node to join the cluster  
because subsequent nodes will inherit the cluster's configuration?

In the case of a node joining an existing cluster, do the default mappings  
on disk or index configuration info in elasticsearch.properties have any  
bearing on how that node functions with regards to mappings and indexes?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 12, 2011, 10:06pm UTC](https://discuss.elastic.co/t/index-and-mapping-creation/5141/2 "2011-08-12T22:06:38Z")

</div>

Hey,

Node level _index_ settings (for example, the elasticsearch.yml  
configuration file, or settings that you provide to the node) are applied to  
an index that is instantiated on that relevant node. If there aren't  
settings to override it when you create the index programmatically, then  
those settings will be applied to the index.

An index instantiated in a node is the low level construct that represent  
an index, its not the index "concept" or the clustered fact that an index  
has been created. Grr, I think I am confusing you.. . Think about it like  
this: When you create an index against a cluster, that index metadata gets  
created in the cluster. Then, when a shard needs is allocated on a node, an  
index level construct is created, which has is configured with settings.  
Those settings are a combination of the index metadata settings, and the  
node level settings (those settings in the node configuration that starts  
with index.xxx).

So, back to you question. You can have the same node level settings (that  
start with index.xxx) and those will apply to any index created. I prefer  
that users will provide the index level settings when you create the index.  
That way, you know what settings you provide it. When a node joins the  
cluster, and a shard for a specific index gets allocate on it, it will use  
those settings provided when you created the index through an API to  
initialize itself.

On Fri, Aug 12, 2011 at 7:27 PM, James Cook [jcook@tracermedia.com](mailto:jcook@tracermedia.com) wrote:

> _Background_
> 
> We embed elasticsearch into our web application, and then let Amazon EC2  
> control the startup or teardown of our server instances based on load  
> metrics. The exact same web app is used across all instances, therefore each  
> new instance brings a new elasticsearch node into existence.
> 
> I am trying to bulletproof some scenarios, and just want to ask what the  
> best practice might be for some of these situations.
> 
> _Programmatic Index/Mapping Creation_
> 
> We are currently defining our index settings in an elasticsearch.properties  
> file that we feed to our embedded ES node when we start it up. We store our  
> mapping files in a location that ES can find and the first time a document  
> is indexed by ES, the mapping files are read in and properly applied.
> 
> One problem, is the mapping files are not automatically loaded if the first  
> request to ES is a query. Is there a setting that can tell ES to load the  
> mapping files when the node is created?
> 
> At the moment we use the same index configuration across all of our  
> indicies. If we wanted to specify different index configurations per index,  
> would we have to resort to a programmatic creation of the indicies via an  
> API call?
> 
> If we switch to programmatic creation of index and mappings, am I right to  
> assume that this only has to happen on the first node to join the cluster  
> because subsequent nodes will inherit the cluster's configuration?
> 
> In the case of a node joining an existing cluster, do the default mappings  
> on disk or index configuration info in elasticsearch.properties have any  
> bearing on how that node functions with regards to mappings and indexes?

---

<div class="post-metadata">

**Author:** ![James\_Cook](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@James\_Cook](https://discuss.elastic.co/u/James_Cook)\
**Post date:** [August 13, 2011, 10:39am UTC](https://discuss.elastic.co/t/index-and-mapping-creation/5141/3 "2011-08-13T10:39:59Z")

</div>

I suspect that an index, once created, is immutable, correct? This statement  
has me questioning.

Then, when a shard needs is allocated on a node, an index level construct is  
created, which has is configured with settings. Those settings are a  
combination of the index metadata settings, and the node level settings  
(those settings in the node configuration that starts with index.xxx).

Once the index is created, the allocation of a shard wouldn't be impacted by  
the particular index configuration of the node local to the shard would it?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 13, 2011, 11:55am UTC](https://discuss.elastic.co/t/index-and-mapping-creation/5141/4 "2011-08-13T11:55:38Z")

</div>

On Sat, Aug 13, 2011 at 1:39 PM, James Cook [jcook@tracermedia.com](mailto:jcook@tracermedia.com) wrote:

> I suspect that an index, once created, is immutable, correct? This  
> statement has me questioning.
> 
> Then, when a shard needs is allocated on a node, an index level construct  
> is created, which has is configured with settings. Those settings are a  
> combination of the index metadata settings, and the node level settings  
> (those settings in the node configuration that starts with index.xxx).
> 
> Once the index is created, the allocation of a shard wouldn't be impacted  
> by the particular index configuration of the node local to the shard would  
> it?

It can be, if you have different index level settings for different nodes.  
Thats why I recommend to provide custom index level settings in the index  
creation API.

---

<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, 3:57am UTC](https://discuss.elastic.co/t/index-and-mapping-creation/5141/5 "2017-07-06T03:57:12Z")

</div>


