# Add mapping with Java API

**URL:** <https://discuss.elastic.co/t/add-mapping-with-java-api/8560>\
**Category:** Elasticsearch\
**Created:** [July 30, 2012, 7:38am UTC](https://discuss.elastic.co/t/add-mapping-with-java-api/8560 "2012-07-30T07:38:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tullio0106](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tullio0106](https://discuss.elastic.co/u/tullio0106)\
**Post date:** [July 30, 2012, 7:38am UTC](https://discuss.elastic.co/t/add-mapping-with-java-api/8560/1 "2012-07-30T07:38:29Z")

</div>

I need to add some mappings after the index was created.  
I can't figure how I can I do that using Java API.  
Could someone provide an example ?  
Is there a Javadoc about Java api?  
Tks  
Tullio

---

<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:** [July 30, 2012, 7:45am UTC](https://discuss.elastic.co/t/add-mapping-with-java-api/8560/2 "2012-07-30T07:45:10Z")

</div>

Look here: [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616)

Javadoc is only available with source code. Download it and attach it to your ES Jar ( on eclipse )

## HTH David

Le 30 juil. 2012 à 09:38, tullio0106 [tbettinazzi@axioma.it](mailto:tbettinazzi@axioma.it) a écrit :

> I need to add some mappings after the index was created.  
> I can't figure how I can I do that using Java API.  
> Could someone provide an example ?  
> Is there a Javadoc about Java api?  
> Tks  
> Tullio

---

<div class="post-metadata">

**Author:** ![tullio0106](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tullio0106](https://discuss.elastic.co/u/tullio0106)\
**Post date:** [July 30, 2012, 9:43am UTC](https://discuss.elastic.co/t/add-mapping-with-java-api/8560/3 "2012-07-30T09:43:05Z")

</div>

Sorry but I don't understand.  
Understanding behaviours from code is quite hard.  
The FactoryBean You indicated where is it ? How can I obtain it? How to use  
it?  
I've the Client object and I use it to execute json but I don't understand  
the code format of the json message I should use to put a new mapping or  
override an existing one.  
Tks  
Tullio

Il giorno lunedì 30 luglio 2012 09:45:10 UTC+2, David Pilato ha scritto:

> Look here:  
> [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616)
> 
> Javadoc is only available with source code. Download it and attach it to  
> your ES Jar ( on eclipse )
> 
> ## HTH David
> 
> Le 30 juil. 2012 à 09:38, tullio0106 [tbettinazzi@axioma.it](mailto:tbettinazzi@axioma.it) a écrit :
> 
> > I need to add some mappings after the index was created.  
> > I can't figure how I can I do that using Java API.  
> > Could someone provide an example ?  
> > Is there a Javadoc about Java api?  
> > Tks  
> > Tullio

Il giorno lunedì 30 luglio 2012 09:45:10 UTC+2, David Pilato ha scritto:

> Look here:  
> [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616)
> 
> Javadoc is only available with source code. Download it and attach it to  
> your ES Jar ( on eclipse )
> 
> ## HTH David
> 
> Le 30 juil. 2012 à 09:38, tullio0106 [tbettinazzi@axioma.it](mailto:tbettinazzi@axioma.it) a écrit :
> 
> > I need to add some mappings after the index was created.  
> > I can't figure how I can I do that using Java API.  
> > Could someone provide an example ?  
> > Is there a Javadoc about Java api?  
> > Tks  
> > Tullio

Il giorno lunedì 30 luglio 2012 09:45:10 UTC+2, David Pilato ha scritto:

> Look here:  
> [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616)
> 
> Javadoc is only available with source code. Download it and attach it to  
> your ES Jar ( on eclipse )
> 
> ## HTH David
> 
> Le 30 juil. 2012 à 09:38, tullio0106 [tbettinazzi@axioma.it](mailto:tbettinazzi@axioma.it) a écrit :
> 
> > I need to add some mappings after the index was created.  
> > I can't figure how I can I do that using Java API.  
> > Could someone provide an example ?  
> > Is there a Javadoc about Java api?  
> > Tks  
> > Tullio

Il giorno lunedì 30 luglio 2012 09:45:10 UTC+2, David Pilato ha scritto:

> Look here:  
> [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616)
> 
> Javadoc is only available with source code. Download it and attach it to  
> your ES Jar ( on eclipse )
> 
> ## HTH David
> 
> Le 30 juil. 2012 à 09:38, tullio0106 [tbettinazzi@axioma.it](mailto:tbettinazzi@axioma.it) a écrit :
> 
> > I need to add some mappings after the index was created.  
> > I can't figure how I can I do that using Java API.  
> > Could someone provide an example ?  
> > Is there a Javadoc about Java api?  
> > Tks  
> > Tullio

---

<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:** [July 30, 2012, 1:12pm UTC](https://discuss.elastic.co/t/add-mapping-with-java-api/8560/4 "2012-07-30T13:12:05Z")

</div>

I forgot to say that's only an example of you can send a mapping to an ES  
cluster.  
Forget the FactoryBean unless you want to use Spring for your project.

This example is perhaps easier to understand:

> <https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/util/ESHelper.java>

[https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/util/ESHelper.java](https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/util/ESHelper.java)

The way I build mapping is by using XContentBuilder.  
Here is an example:  
[https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/api/settings/rivers/abstractfs/helper/AbstractFSRiverHelper.java#L143](https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/api/settings/rivers/abstractfs/helper/AbstractFSRiverHelper.java#L143)  
[https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/api/settings/rivers/abstractfs/helper/AbstractFSRiverHelper.java#L143](https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/api/settings/rivers/abstractfs/helper/AbstractFSRiverHelper.java#L143)

I hope this can help you.

David 😉  
Twitter : @dadoonet / @elasticsearchfr

Le 30 juil. 2012 à 11:43, tullio0106 \< tbettinazzi@axioma.it  
[mailto:tbettinazzi@axioma.it](mailto:tbettinazzi@axioma.it) \> a écrit :

> ```
> Sorry but I don't understand.
> Understanding behaviours from code is quite hard.
> The FactoryBean You indicated where is it ? How can I obtain it? How to
> 
> ```
> 
> use it?  
> I've the Client object and I use it to execute json but I don't understand  
> the code format of the json message I should use to put a new mapping or  
> override an existing one.  
> Tks  
> Tullio
> 
> ```
> Il giorno lunedì 30 luglio 2012 09:45:10 UTC+2, David Pilato ha scritto:
> > > Look here:
> > > https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616
> 
> ```
> 
> > ```
> > Javadoc is only available with source code. Download it and attach it
> > 
> > ```
> > 
> > to your ES Jar ( on eclipse )
> > 
> > ```
> > HTH
> > David
> > --
> > 
> > Le 30 juil. 2012 à 09:38, tullio0106 <
> > 
> > ```
> > 
> > [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616)  
> > tbettinazzi@axioma.it [mailto:tbettinazzi@axioma.it](mailto:tbettinazzi@axioma.it) \> a écrit :
> > 
> > ```
> > > I need to add some mappings after the index was created.
> > > I can't figure how I can I do that using Java API.
> > > Could someone provide an example ?
> > > Is there a Javadoc about Java api?
> > > Tks
> > > Tullio
> > 
> > Il giorno lunedì 30 luglio 2012 09:45:10 UTC+2, David Pilato ha
> > 
> > ```
> > 
> > scritto:  
> > \> \> \> Look here:  
> > \> \> \> [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616)
> > 
> > > ```
> > > Javadoc is only available with source code. Download it and attach
> > > 
> > > ```
> > > 
> > > it to your ES Jar ( on eclipse )
> > > 
> > > ```
> > > HTH
> > > David
> > > --
> > > 
> > > Le 30 juil. 2012 à 09:38, tullio0106 <
> > > 
> > > ```
> > > 
> > > [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616)  
> > > tbettinazzi@axioma.it [mailto:tbettinazzi@axioma.it](mailto:tbettinazzi@axioma.it) \> a écrit :
> > > 
> > > ```
> > > > I need to add some mappings after the index was created.
> > > > I can't figure how I can I do that using Java API.
> > > > Could someone provide an example ?
> > > > Is there a Javadoc about Java api?
> > > > Tks
> > > > Tullio
> > > 
> > > Il giorno lunedì 30 luglio 2012 09:45:10 UTC+2, David Pilato ha
> > > 
> > > ```
> > > 
> > > scritto:  
> > > \> \> \> \> Look here:  
> > > \> \> \> \> [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616)
> > > 
> > > > ```
> > > > Javadoc is only available with source code. Download it and
> > > > 
> > > > ```
> > > > 
> > > > attach it to your ES Jar ( on eclipse )
> > > > 
> > > > ```
> > > > HTH
> > > > David
> > > > --
> > > > 
> > > > Le 30 juil. 2012 à 09:38, tullio0106 <
> > > > 
> > > > ```
> > > > 
> > > > [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616)  
> > > > tbettinazzi@axioma.it [mailto:tbettinazzi@axioma.it](mailto:tbettinazzi@axioma.it) \> a écrit :
> > > > 
> > > > ```
> > > > > I need to add some mappings after the index was created.
> > > > > I can't figure how I can I do that using Java API.
> > > > > Could someone provide an example ?
> > > > > Is there a Javadoc about Java api?
> > > > > Tks
> > > > > Tullio
> > > > 
> > > > Il giorno lunedì 30 luglio 2012 09:45:10 UTC+2, David Pilato
> > > > 
> > > > ```
> > > > 
> > > > ha scritto:  
> > > > \> \> \> \> \> Look here:  
> > > > \> \> \> \> \> [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616)
> > > > 
> > > > > ```
> > > > > Javadoc is only available with source code. Download it
> > > > > 
> > > > > ```
> > > > > 
> > > > > and attach it to your ES Jar ( on eclipse )
> > > > > 
> > > > > ```
> > > > > HTH
> > > > > David
> > > > > --
> > > > > 
> > > > > Le 30 juil. 2012 à 09:38, tullio0106 <
> > > > > 
> > > > > ```
> > > > > 
> > > > > [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616)  
> > > > > tbettinazzi@axioma.it [mailto:tbettinazzi@axioma.it](mailto:tbettinazzi@axioma.it) \> a écrit :
> > > > > 
> > > > > ```
> > > > > > I need to add some mappings after the index was created.
> > > > > > I can't figure how I can I do that using Java API.
> > > > > > Could someone provide an example ?
> > > > > > Is there a Javadoc about Java api?
> > > > > > Tks
> > > > > > Tullio
> > > > > > > > > > > > > > >
> > > > > 
> > > > > ```

---

<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:18am UTC](https://discuss.elastic.co/t/add-mapping-with-java-api/8560/5 "2017-07-06T03:18:28Z")

</div>


