# Updating settings and mapping with java API

**URL:** <https://discuss.elastic.co/t/updating-settings-and-mapping-with-java-api/6566>\
**Category:** Elasticsearch\
**Created:** [February 1, 2012, 4:19pm UTC](https://discuss.elastic.co/t/updating-settings-and-mapping-with-java-api/6566 "2012-02-01T16:19:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![louis\_gueye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/louis_gueye/32/2772_2.png) [@louis\_gueye](https://discuss.elastic.co/u/louis_gueye)\
**Post date:** [February 1, 2012, 4:19pm UTC](https://discuss.elastic.co/t/updating-settings-and-mapping-with-java-api/6566/1 "2012-02-01T16:19:12Z")

</div>

Hi all,

I'm trying to achieve this sequence with the java API :

1 - create a node  
------------------- NodeFactory  
_Node node = NodeBuilder.nodeBuilder() //_

- 

```
           .local(true).data(true) //*

```

- 

```
           .settings(ImmutableSettings.settingsBuilder() //*

```

- 

```
               .loadFromClasspath("elasticsearch/elasticsearch.yml"))

```

//\*

- 

```
           .node();*

```

------------------- elasticsearch.yml  
_path:_

- data: target\*

2 - obtain a client from the node  
_Client client = node.client();_

3 - create an index

- 

```
   if

```

(client.admin().indices().prepareExists("my-index").execute().actionGet().exists())  
{\*  
\*  
client.admin().indices().prepareDelete("my-index").execute().actionGet();\*

- 

```
   }*

```

- 

client.admin().indices().prepareCreate("my-index").execute().actionGet();\*

4 - update the index settings+mappings

- // load my-index.json as string\*
- 

client.admin().indices().prepareUpdateSettings().setSettings(settings).setIndices("my-index").execute().actionGet();  
\*

-------------------- elasticsearch/settings/my-index.json

_{_

- "settings": {\*
- 

```
   "index" : {*

```

- 

```
       "analysis" : {*

```

- 

```
           "analyzer" : {*

```

- 

```
               "default" : {*

```

- 

```
                   "type" : "snowball",*

```

- 

```
                   "language" : "French",*

```

- 

```
                   "filter": ["asciifolding","lowercase"]*

```

- 

```
               },*

```

- 

```
               "sortable": {*

```

- 

```
                   "tokenizer": "keyword",*

```

- 

```
                   "filter": ["lowercase"]*

```

- 

```
               }*

```

- 

```
           }*

```

- 

```
       }*

```

- 

```
   }*

```

- },\*
- "mappings": {\*
- 

```
   "job_posting" : {*

```

- 

```
       "properties" : {*

```

- 

```
           "id" : {*

```

- 

```
               "type" : "long",*

```

- 

```
               "index" : "not_analyzed"*

```

- 

```
           },*

```

- 

```
           "job" : {*

```

- 

```
               "dynamic" : "true",*

```

- 

```
               "properties" : {*

```

- 

```
                   "howToApply" : {*

```

- 

```
                       "dynamic" : "true",*

```

- 

```
                       "properties" : {*

```

- 

```
                           "reference" : {*

```

- 

```
                               "index" : "not_analyzed",*

```

- 

```
                               "type" : "string"*

```

- 

```
                           }*

```

- 

```
                       }*

```

- 

```
                   }*

```

- 

```
               }*

```

- 

```
           }*

```

- 

```
       }*

```

- 

```
   }*

```

- }\*  
_}_
- 
- 

It appears that the sequence doesn't work for me because when I read the  
index mapping before querying it's not the same as the one I put.  
For example, at runtime, job.howToApply.reference is analysed while I  
marked it as "not\_analysed"

This leads to false search results because the default mapping doesn't suit  
me.

Any hints on how I can update a mappings+settings configuration in java ?

--  
Cordialement/Regards,

Louis GUEYE  
linkedin [http://fr.linkedin.com/in/louisgueye](http://fr.linkedin.com/in/louisgueye) |  
blog[http://deepintojee.wordpress.com/](http://deepintojee.wordpress.com/)|  
twitter [http://twitter.com/#!/lgueye](http://twitter.com/#%21/lgueye)

---

<div class="post-metadata">

**Author:** ![louis\_gueye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/louis_gueye/32/2772_2.png) [@louis\_gueye](https://discuss.elastic.co/u/louis_gueye)\
**Post date:** [February 1, 2012, 5:18pm UTC](https://discuss.elastic.co/t/updating-settings-and-mapping-with-java-api/6566/2 "2012-02-01T17:18:17Z")

</div>

Well, as suggested by a colleague of mine, I splited the settings+mapping  
in 2 instructions

The above sequence becomes :

1 - (same)  
2 - (same)  
3 - (same)  
4 - update the index settings  
4 - update the index mappings

_// settingsAsString is the content of the file elasticsearch/settings/my-  
index.json_  
\*  
client.admin().indices().prepareUpdateSettings().setSettings(settingsAsString).setIndices(  
\*

- 

```
   "my-index").execute().actionGet();*

```

-------------------------------- elasticsearch/settings/my-index.json  
_{_

- "index" : {\*
- 

```
   "analysis" : {*

```

- 

```
       "analyzer" : {*

```

- 

```
           "default" : {*

```

- 

```
               "type" : "standard",*

```

- 

```
               "filter": ["standard", "asciifolding","lowercase"]*

```

- 

```
           },*

```

- 

```
           "sortable": {*

```

- 

```
               "tokenizer": "keyword",*

```

- 

```
               "filter": ["lowercase"]*

```

- 

```
           }*

```

- 

```
       }*

```

- 

```
   }*

```

- }\*
- 
- 

_}_

5 - update the mapping settings

_// mappingAsString is the content of the file  
elasticsearch/mappings/job\_posting.json_  
_client.admin().indices().preparePutMapping().setIndices(_  
\*  
"my-index").setType("job\_posting").setSource(mappingAsString).execute()\*

- 

```
   .actionGet();*

```

-------------------------------- elasticsearch/mappings/job\_posting.json

- 

```
   "job_posting" : {*

```

- 

```
       "properties" : {*

```

- 

```
           "id" : {*

```

- 

```
               "type" : "long",*

```

- 

```
               "index" : "not_analyzed"*

```

- 

```
           },*

```

- 

```
           "job" : {*

```

- 

```
               "dynamic" : "true",*

```

- 

```
               "properties" : {*

```

- 

```
                   "howToApply" : {*

```

- 

```
                       "dynamic" : "true",*

```

- 

```
                       "properties" : {*

```

- 

```
                           "reference" : {*

```

- 

```
                               "index" : "not_analyzed",*

```

- 

```
                               "type" : "string"*

```

- 

```
                           }*

```

- 

```
                       }*

```

- 

```
                   }*

```

- 

```
               }*

```

- 

```
           }*

```

- 

```
       }*

```

- 

```
   }*

```

- 
- 

Same result here : the new settings have no effect.

How do I know that ?  
If I configure _elasticsearch/elasticsearch.yml_ with the above index  
settings I can index job.howToApply.reference with _"Ingénieur  
informaticien"_ and retrieve it with "_inge_".

With this configuration I can't.

Any ideas ?

Thx for your help.  
\*  
\*  
2012/2/1 louis gueye [louis.gueye@gmail.com](mailto:louis.gueye@gmail.com)

> Hi all,
> 
> I'm trying to achieve this sequence with the java API :
> 
> 1 - create a node  
> ------------------- NodeFactory  
> _Node node = NodeBuilder.nodeBuilder() //_
> 
> - 
> 
> ```
> .local(true).data(true) //*
> 
> ```
> 
> - 
> 
> ```
> .settings(ImmutableSettings.settingsBuilder() //*
> 
> ```
> 
> - 
> 
> .loadFromClasspath("elasticsearch/elasticsearch.yml")) //\*
> 
> - 
> 
> ```
> .node();*
> 
> ```
> 
> ------------------- elasticsearch.yml  
> _path:_
> 
> - data: target\*
> 
> 2 - obtain a client from the node  
> _Client client = node.client();_
> 
> 3 - create an index
> 
> - 
> 
> ```
> if
> 
> ```
> 
> (client.admin().indices().prepareExists("my-index").execute().actionGet().exists())  
> {\*  
> \*  
> client.admin().indices().prepareDelete("my-index").execute().actionGet();\*
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> client.admin().indices().prepareCreate("my-index").execute().actionGet();\*
> 
> 4 - update the index settings+mappings
> 
> - // load my-index.json as string\*
> - 
> 
> client.admin().indices().prepareUpdateSettings().setSettings(settings).setIndices("my-index").execute().actionGet();  
> \*
> 
> -------------------- elasticsearch/settings/my-index.json
> 
> _{_
> 
> - "settings": {\*
> - 
> 
> ```
> "index" : {*
> 
> ```
> 
> - 
> 
> ```
> "analysis" : {*
> 
> ```
> 
> - 
> 
> ```
> "analyzer" : {*
> 
> ```
> 
> - 
> 
> ```
> "default" : {*
> 
> ```
> 
> - 
> 
> ```
> "type" : "snowball",*
> 
> ```
> 
> - 
> 
> ```
> "language" : "French",*
> 
> ```
> 
> - 
> 
> ```
> "filter": ["asciifolding","lowercase"]*
> 
> ```
> 
> - 
> 
> ```
> },*
> 
> ```
> 
> - 
> 
> ```
> "sortable": {*
> 
> ```
> 
> - 
> 
> ```
> "tokenizer": "keyword",*
> 
> ```
> 
> - 
> 
> ```
> "filter": ["lowercase"]*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - },\*
> - "mappings": {\*
> - 
> 
> ```
> "job_posting" : {*
> 
> ```
> 
> - 
> 
> ```
> "properties" : {*
> 
> ```
> 
> - 
> 
> ```
> "id" : {*
> 
> ```
> 
> - 
> 
> ```
> "type" : "long",*
> 
> ```
> 
> - 
> 
> ```
> "index" : "not_analyzed"*
> 
> ```
> 
> - 
> 
> ```
> },*
> 
> ```
> 
> - 
> 
> ```
> "job" : {*
> 
> ```
> 
> - 
> 
> ```
> "dynamic" : "true",*
> 
> ```
> 
> - 
> 
> ```
> "properties" : {*
> 
> ```
> 
> - 
> 
> ```
> "howToApply" : {*
> 
> ```
> 
> - 
> 
> ```
> "dynamic" : "true",*
> 
> ```
> 
> - 
> 
> ```
> "properties" : {*
> 
> ```
> 
> - 
> 
> ```
> "reference" : {*
> 
> ```
> 
> - 
> 
> ```
> "index" : "not_analyzed",*
> 
> ```
> 
> - 
> 
> ```
> "type" : "string"*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - }\*  
> _}_
> - 
> - 
> 
> It appears that the sequence doesn't work for me because when I read the  
> index mapping before querying it's not the same as the one I put.  
> For example, at runtime, job.howToApply.reference is analysed while I  
> marked it as "not\_analysed"
> 
> This leads to false search results because the default mapping doesn't  
> suit me.
> 
> Any hints on how I can update a mappings+settings configuration in java ?
> 
> --  
> Cordialement/Regards,
> 
> Louis GUEYE  
> linkedin [http://fr.linkedin.com/in/louisgueye](http://fr.linkedin.com/in/louisgueye) | blog[http://deepintojee.wordpress.com/](http://deepintojee.wordpress.com/)|  
> twitter [http://twitter.com/#!/lgueye](http://twitter.com/#%21/lgueye)

--  
Cordialement/Regards,

Louis GUEYE  
linkedin [http://fr.linkedin.com/in/louisgueye](http://fr.linkedin.com/in/louisgueye) |  
blog[http://deepintojee.wordpress.com/](http://deepintojee.wordpress.com/)|  
twitter [http://twitter.com/#!/lgueye](http://twitter.com/#%21/lgueye)

---

<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:** [February 5, 2012, 10:43am UTC](https://discuss.elastic.co/t/updating-settings-and-mapping-with-java-api/6566/3 "2012-02-05T10:43:19Z")

</div>

Update settings allows only to change specific settings are runtime: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html).

The json you have with the settings and the mappings should be broken down, and provided during the create index API.

On Wednesday, February 1, 2012 at 7:18 PM, louis gueye wrote:

> Well, as suggested by a colleague of mine, I splited the settings+mapping in 2 instructions
> 
> The above sequence becomes :
> 
> 1 - (same)  
> 2 - (same)  
> 3 - (same)  
> 4 - update the index settings  
> 4 - update the index mappings
> 
> // settingsAsString is the content of the file elasticsearch/settings/my-index.json  
> client.admin().indices().prepareUpdateSettings().setSettings(settingsAsString).setIndices(  
> "my-index").execute().actionGet();
> 
> -------------------------------- elasticsearch/settings/my-index.json  
> {  
> "index" : {  
> "analysis" : {  
> "analyzer" : {  
> "default" : {  
> "type" : "standard",  
> "filter": ["standard", "asciifolding","lowercase"]  
> },  
> "sortable": {  
> "tokenizer": "keyword",  
> "filter": ["lowercase"]  
> }  
> }  
> }  
> }
> 
> }
> 
> 5 - update the mapping settings
> 
> // mappingAsString is the content of the file elasticsearch/mappings/job\_posting.json  
> client.admin().indices().preparePutMapping().setIndices(  
> "my-index").setType("job\_posting").setSource(mappingAsString).execute()  
> .actionGet();
> 
> -------------------------------- elasticsearch/mappings/job\_posting.json  
> "job\_posting" : {  
> "properties" : {  
> "id" : {  
> "type" : "long",  
> "index" : "not\_analyzed"  
> },  
> "job" : {  
> "dynamic" : "true",  
> "properties" : {  
> "howToApply" : {  
> "dynamic" : "true",  
> "properties" : {  
> "reference" : {  
> "index" : "not\_analyzed",  
> "type" : "string"  
> }  
> }  
> }  
> }  
> }  
> }  
> }
> 
> Same result here : the new settings have no effect.
> 
> How do I know that ?  
> If I configure elasticsearch/elasticsearch.yml with the above index settings I can index job.howToApply.reference with "Ingénieur informaticien" and retrieve it with "_inge_".
> 
> With this configuration I can't.
> 
> Any ideas ?
> 
> Thx for your help.
> 
> 2012/2/1 louis gueye \<[louis.gueye@gmail.com](mailto:louis.gueye@gmail.com) ([mailto:louis.gueye@gmail.com](mailto:louis.gueye@gmail.com))\>
> 
> > Hi all,
> > 
> > I'm trying to achieve this sequence with the java API :
> > 
> > 1 - create a node  
> > ------------------- NodeFactory  
> > Node node = NodeBuilder.nodeBuilder() //  
> > .local(true).data(true) //  
> > .settings(ImmutableSettings.settingsBuilder() //  
> > .loadFromClasspath("elasticsearch/elasticsearch.yml")) //  
> > .node();
> > 
> > ------------------- elasticsearch.yml  
> > path:  
> > data: target
> > 
> > 2 - obtain a client from the node  
> > Client client = node.client();
> > 
> > 3 - create an index  
> > if (client.admin().indices().prepareExists("my-index").execute().actionGet().exists()) {  
> > client.admin().indices().prepareDelete("my-index").execute().actionGet();  
> > }  
> > client.admin().indices().prepareCreate("my-index").execute().actionGet();
> > 
> > 4 - update the index settings+mappings  
> > // load my-index.json as string  
> > client.admin().indices().prepareUpdateSettings().setSettings(settings).setIndices("my-index").execute().actionGet();
> > 
> > -------------------- elasticsearch/settings/my-index.json
> > 
> > {  
> > "settings": {  
> > "index" : {  
> > "analysis" : {  
> > "analyzer" : {  
> > "default" : {  
> > "type" : "snowball",  
> > "language" : "French",  
> > "filter": ["asciifolding","lowercase"]  
> > },  
> > "sortable": {  
> > "tokenizer": "keyword",  
> > "filter": ["lowercase"]  
> > }  
> > }  
> > }  
> > }  
> > },  
> > "mappings": {  
> > "job\_posting" : {  
> > "properties" : {  
> > "id" : {  
> > "type" : "long",  
> > "index" : "not\_analyzed"  
> > },  
> > "job" : {  
> > "dynamic" : "true",  
> > "properties" : {  
> > "howToApply" : {  
> > "dynamic" : "true",  
> > "properties" : {  
> > "reference" : {  
> > "index" : "not\_analyzed",  
> > "type" : "string"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > It appears that the sequence doesn't work for me because when I read the index mapping before querying it's not the same as the one I put.  
> > For example, at runtime, job.howToApply.reference is analysed while I marked it as "not\_analysed"
> > 
> > This leads to false search results because the default mapping doesn't suit me.
> > 
> > Any hints on how I can update a mappings+settings configuration in java ?
> > 
> > --  
> > Cordialement/Regards,
> > 
> > Louis GUEYE  
> > linkedin ([http://fr.linkedin.com/in/louisgueye](http://fr.linkedin.com/in/louisgueye)) | blog ([http://deepintojee.wordpress.com/](http://deepintojee.wordpress.com/)) | twitter ([http://twitter.com/#!/lgueye](http://twitter.com/#%21/lgueye))
> 
> --  
> Cordialement/Regards,
> 
> Louis GUEYE  
> linkedin ([http://fr.linkedin.com/in/louisgueye](http://fr.linkedin.com/in/louisgueye)) | blog ([http://deepintojee.wordpress.com/](http://deepintojee.wordpress.com/)) | twitter ([http://twitter.com/#!/lgueye](http://twitter.com/#%21/lgueye))

---

<div class="post-metadata">

**Author:** ![louis\_gueye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/louis_gueye/32/2772_2.png) [@louis\_gueye](https://discuss.elastic.co/u/louis_gueye)\
**Post date:** [February 6, 2012, 8:57am UTC](https://discuss.elastic.co/t/updating-settings-and-mapping-with-java-api/6566/4 "2012-02-06T08:57:11Z")

</div>

Thx you for the reply.

2012/2/5 Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com)

> Update settings allows only to change specific settings are runtime:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html)  
> .
> 
> The json you have with the settings and the mappings should be broken  
> down, and provided during the create index API.
> 
> On Wednesday, February 1, 2012 at 7:18 PM, louis gueye wrote:
> 
> Well, as suggested by a colleague of mine, I splited the settings+mapping  
> in 2 instructions
> 
> The above sequence becomes :
> 
> 1 - (same)  
> 2 - (same)  
> 3 - (same)  
> 4 - update the index settings  
> 4 - update the index mappings
> 
> _// settingsAsString is the content of the file elasticsearch/settings/my-  
> index.json_  
> \*  
> client.admin().indices().prepareUpdateSettings().setSettings(settingsAsString).setIndices(  
> \*
> 
> - 
> 
> ```
> "my-index").execute().actionGet();*
> 
> ```
> 
> -------------------------------- elasticsearch/settings/my-index.json  
> _{_
> 
> - "index" : {\*
> - 
> 
> ```
> "analysis" : {*
> 
> ```
> 
> - 
> 
> ```
> "analyzer" : {*
> 
> ```
> 
> - 
> 
> ```
> "default" : {*
> 
> ```
> 
> - 
> 
> ```
> "type" : "standard",*
> 
> ```
> 
> - 
> 
> ```
> "filter": ["standard", "asciifolding","lowercase"]*
> 
> ```
> 
> - 
> 
> ```
> },*
> 
> ```
> 
> - 
> 
> ```
> "sortable": {*
> 
> ```
> 
> - 
> 
> ```
> "tokenizer": "keyword",*
> 
> ```
> 
> - 
> 
> ```
> "filter": ["lowercase"]*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - }\*
> - 
> - 
> 
> _}_
> 
> 5 - update the mapping settings
> 
> _// mappingAsString is the content of the file  
> elasticsearch/mappings/job\_posting.json_  
> _client.admin().indices().preparePutMapping().setIndices(_  
> \*  
> "my-index").setType("job\_posting").setSource(mappingAsString).execute()\*
> 
> - 
> 
> ```
> .actionGet();*
> 
> ```
> 
> -------------------------------- elasticsearch/mappings/job\_posting.json
> 
> - 
> 
> ```
> "job_posting" : {*
> 
> ```
> 
> - 
> 
> ```
> "properties" : {*
> 
> ```
> 
> - 
> 
> ```
> "id" : {*
> 
> ```
> 
> - 
> 
> ```
> "type" : "long",*
> 
> ```
> 
> - 
> 
> ```
> "index" : "not_analyzed"*
> 
> ```
> 
> - 
> 
> ```
> },*
> 
> ```
> 
> - 
> 
> ```
> "job" : {*
> 
> ```
> 
> - 
> 
> ```
> "dynamic" : "true",*
> 
> ```
> 
> - 
> 
> ```
> "properties" : {*
> 
> ```
> 
> - 
> 
> ```
> "howToApply" : {*
> 
> ```
> 
> - 
> 
> ```
> "dynamic" : "true",*
> 
> ```
> 
> - 
> 
> ```
> "properties" : {*
> 
> ```
> 
> - 
> 
> ```
> "reference" : {*
> 
> ```
> 
> - 
> 
> ```
> "index" : "not_analyzed",*
> 
> ```
> 
> - 
> 
> ```
> "type" : "string"*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> - 
> 
> Same result here : the new settings have no effect.
> 
> How do I know that ?  
> If I configure _elasticsearch/elasticsearch.yml_ with the above index  
> settings I can index job.howToApply.reference with _"Ingénieur  
> informaticien"_ and retrieve it with "_inge_".
> 
> With this configuration I can't.
> 
> Any ideas ?
> 
> Thx for your help.  
> \*  
> \*  
> 2012/2/1 louis gueye [louis.gueye@gmail.com](mailto:louis.gueye@gmail.com)
> 
> Hi all,
> 
> I'm trying to achieve this sequence with the java API :
> 
> 1 - create a node  
> ------------------- NodeFactory  
> _Node node = NodeBuilder.nodeBuilder() //_
> 
> - 
> 
> ```
> .local(true).data(true) //*
> 
> ```
> 
> - 
> 
> ```
> .settings(ImmutableSettings.settingsBuilder() //*
> 
> ```
> 
> - 
> 
> .loadFromClasspath("elasticsearch/elasticsearch.yml")) //\*
> 
> - 
> 
> ```
> .node();*
> 
> ```
> 
> ------------------- elasticsearch.yml  
> _path:_
> 
> - data: target\*
> 
> 2 - obtain a client from the node  
> _Client client = node.client();_
> 
> 3 - create an index
> 
> - 
> 
> ```
> if
> 
> ```
> 
> (client.admin().indices().prepareExists("my-index").execute().actionGet().exists())  
> {\*  
> \*  
> client.admin().indices().prepareDelete("my-index").execute().actionGet();\*
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> client.admin().indices().prepareCreate("my-index").execute().actionGet();\*
> 
> 4 - update the index settings+mappings
> 
> - // load my-index.json as string\*
> - 
> 
> client.admin().indices().prepareUpdateSettings().setSettings(settings).setIndices("my-index").execute().actionGet();  
> \*
> 
> -------------------- elasticsearch/settings/my-index.json
> 
> _{_
> 
> - "settings": {\*
> - 
> 
> ```
> "index" : {*
> 
> ```
> 
> - 
> 
> ```
> "analysis" : {*
> 
> ```
> 
> - 
> 
> ```
> "analyzer" : {*
> 
> ```
> 
> - 
> 
> ```
> "default" : {*
> 
> ```
> 
> - 
> 
> ```
> "type" : "snowball",*
> 
> ```
> 
> - 
> 
> ```
> "language" : "French",*
> 
> ```
> 
> - 
> 
> ```
> "filter": ["asciifolding","lowercase"]*
> 
> ```
> 
> - 
> 
> ```
> },*
> 
> ```
> 
> - 
> 
> ```
> "sortable": {*
> 
> ```
> 
> - 
> 
> ```
> "tokenizer": "keyword",*
> 
> ```
> 
> - 
> 
> ```
> "filter": ["lowercase"]*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - },\*
> - "mappings": {\*
> - 
> 
> ```
> "job_posting" : {*
> 
> ```
> 
> - 
> 
> ```
> "properties" : {*
> 
> ```
> 
> - 
> 
> ```
> "id" : {*
> 
> ```
> 
> - 
> 
> ```
> "type" : "long",*
> 
> ```
> 
> - 
> 
> ```
> "index" : "not_analyzed"*
> 
> ```
> 
> - 
> 
> ```
> },*
> 
> ```
> 
> - 
> 
> ```
> "job" : {*
> 
> ```
> 
> - 
> 
> ```
> "dynamic" : "true",*
> 
> ```
> 
> - 
> 
> ```
> "properties" : {*
> 
> ```
> 
> - 
> 
> ```
> "howToApply" : {*
> 
> ```
> 
> - 
> 
> ```
> "dynamic" : "true",*
> 
> ```
> 
> - 
> 
> ```
> "properties" : {*
> 
> ```
> 
> - 
> 
> ```
> "reference" : {*
> 
> ```
> 
> - 
> 
> ```
> "index" : "not_analyzed",*
> 
> ```
> 
> - 
> 
> ```
> "type" : "string"*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - }\*  
> _}_
> - 
> - 
> 
> It appears that the sequence doesn't work for me because when I read the  
> index mapping before querying it's not the same as the one I put.  
> For example, at runtime, job.howToApply.reference is analysed while I  
> marked it as "not\_analysed"
> 
> This leads to false search results because the default mapping doesn't  
> suit me.
> 
> Any hints on how I can update a mappings+settings configuration in java ?
> 
> --  
> Cordialement/Regards,
> 
> Louis GUEYE  
> linkedin [http://fr.linkedin.com/in/louisgueye](http://fr.linkedin.com/in/louisgueye) | blog[http://deepintojee.wordpress.com/](http://deepintojee.wordpress.com/)|  
> twitter [http://twitter.com/#!/lgueye](http://twitter.com/#%21/lgueye)
> 
> --  
> Cordialement/Regards,
> 
> Louis GUEYE  
> linkedin [http://fr.linkedin.com/in/louisgueye](http://fr.linkedin.com/in/louisgueye) | blog[http://deepintojee.wordpress.com/](http://deepintojee.wordpress.com/)|  
> twitter [http://twitter.com/#!/lgueye](http://twitter.com/#%21/lgueye)

--  
Cordialement/Regards,

Louis GUEYE  
linkedin [http://fr.linkedin.com/in/louisgueye](http://fr.linkedin.com/in/louisgueye) |  
blog[http://deepintojee.wordpress.com/](http://deepintojee.wordpress.com/)|  
twitter [http://twitter.com/#!/lgueye](http://twitter.com/#%21/lgueye)

---

<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:40am UTC](https://discuss.elastic.co/t/updating-settings-and-mapping-with-java-api/6566/5 "2017-07-06T03:40:29Z")

</div>


