# Java API for Mappings

**URL:** <https://discuss.elastic.co/t/java-api-for-mappings/3142>\
**Category:** Elasticsearch\
**Created:** [July 23, 2010, 3:06pm UTC](https://discuss.elastic.co/t/java-api-for-mappings/3142 "2010-07-23T15:06:01Z")\
**Posts on this page:** 3\
**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:** [July 23, 2010, 3:06pm UTC](https://discuss.elastic.co/t/java-api-for-mappings/3142/1 "2010-07-23T15:06:01Z")

</div>

Hi,

How do I use the Java API's to add a mapping to Elastic Search?

At startup, I would like to check and see if a mapping (for a specific set  
of types) exists yet. If it doesn't, I will add it.

Also, do I add a mapping file to each node in my cluster, or when I add a  
mapping file to one node, does it apply to all nodes?

One more, I want to run the mapping file into the node when it initializes.  
If it is going to use mapping files from other nodes, do I have to wait for  
a specific event to occur before I can check for the presence of the mapping  
file?

Thanks.

---

<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:** [July 23, 2010, 3:11pm UTC](https://discuss.elastic.co/t/java-api-for-mappings/3142/2 "2010-07-23T15:11:46Z")

</div>

There is an API to put mappings, it is exposed as a Java API (under the  
indices admin API). You can get the current mappings from the cluster state  
Java API. Once you put a mapping, it is automatically shared between all the  
different nodes (and future nodes) in the cluster and stored as part of the  
cluster meta data.

-shay.banon

On Fri, Jul 23, 2010 at 6:06 PM, James Cook [jcook@tracermedia.com](mailto:jcook@tracermedia.com) wrote:

> Hi,
> 
> How do I use the Java API's to add a mapping to Elastic Search?
> 
> At startup, I would like to check and see if a mapping (for a specific set  
> of types) exists yet. If it doesn't, I will add it.
> 
> Also, do I add a mapping file to each node in my cluster, or when I add a  
> mapping file to one node, does it apply to all nodes?
> 
> One more, I want to run the mapping file into the node when it initializes.  
> If it is going to use mapping files from other nodes, do I have to wait for  
> a specific event to occur before I can check for the presence of the mapping  
> file?
> 
> Thanks.

---

<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, 4:21am UTC](https://discuss.elastic.co/t/java-api-for-mappings/3142/3 "2017-07-06T04:21:44Z")

</div>


