# Issue Upgrading from 2.3.1 to 6.1.0

**URL:** <https://discuss.elastic.co/t/issue-upgrading-from-2-3-1-to-6-1-0/117063>\
**Category:** Elasticsearch\
**Created:** [January 25, 2018, 3:18pm UTC](https://discuss.elastic.co/t/issue-upgrading-from-2-3-1-to-6-1-0/117063 "2018-01-25T15:18:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam\_Schlaak](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@Sam\_Schlaak](https://discuss.elastic.co/u/Sam_Schlaak)\
**Post date:** [January 25, 2018, 3:18pm UTC](https://discuss.elastic.co/t/issue-upgrading-from-2-3-1-to-6-1-0/117063/1 "2018-01-25T15:18:05Z")

</div>

Hello.

My application uses the Elasticsearch Java API to communicate with the cluster. Previously, when creating an index and assigning a mapping, it was done as follows:

create:  
`client.admin().indices().prepareCreate(indexName).execute().actionGet();`

assign mapping:  
`PutMappingRequest pmr = Requests.putMappingRequest(indexName).type(userDocumentTypeName).source(userDocumentTypeMapping); client.admin().indices().putMapping(pmr).actionGet();`

However, when updating to v6.1.0, this code does not work. It errors out with the message "Caused by: java.lang.IllegalArgumentException: mapping source must be pairs of fieldnames and properties definition."

My variable userDocumentTypeMapping is a string representation of a JSON object. It seems that this is not the format accepted any longer when creating a mapping. I am wondering what the proper format is and how I should go about converting my String to that format.

---

<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 25, 2018, 3:40pm UTC](https://discuss.elastic.co/t/issue-upgrading-from-2-3-1-to-6-1-0/117063/2 "2018-01-25T15:40:25Z")

</div>

You can use I think `setSource(userDocumentTypeMapping, XContentType.JSON)` or something like this.

See

> <https://github.com/elastic/elasticsearch/blob/6.1/core/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java#L87-L90>

---

<div class="post-metadata">

**Author:** ![Sam\_Schlaak](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@Sam\_Schlaak](https://discuss.elastic.co/u/Sam_Schlaak)\
**Post date:** [January 25, 2018, 3:47pm UTC](https://discuss.elastic.co/t/issue-upgrading-from-2-3-1-to-6-1-0/117063/3 "2018-01-25T15:47:39Z")

</div>

This did the trick: (.source rather than .setSource)  
`PutMappingRequest pmr = Requests.putMappingRequest(indexName).type(userDocumentTypeName).source(userDocumentTypeMapping, XContentType.JSON);`

That got me past the error I mentioned. Now I've got a different error regarding the mapping itself, but at least it's not the same one. I may be back if I get stuck again, haha. Thank you for the help, David!

---

<div class="post-metadata">

**Author:** ![Sam\_Schlaak](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@Sam\_Schlaak](https://discuss.elastic.co/u/Sam_Schlaak)\
**Post date:** [January 29, 2018, 7:59pm UTC](https://discuss.elastic.co/t/issue-upgrading-from-2-3-1-to-6-1-0/117063/4 "2018-01-29T19:59:59Z")

</div>

@dadoonet If you could please be of any help...I've run into another issue.

I'm trying to add a tokenizer and three analyzers to my index at creation time. Here's the code:  
client.admin().indices().prepareCreate(indexName).setSettings(Settings.builder().loadFromSource(jsonBuilder()  
.startObject()  
.startObject("analysis")  
.startObject("tokenizer")  
.startObject("username\_tokenizer")  
.field("type", "nGram")  
.field("min\_gram", 1)  
.field("max\_gram", 80)  
.endObject()  
.endObject()  
.startObject("analyzer")  
.startObject("string\_lowercase")  
.field("type", "custom")  
.field("tokenizer", "keyword")  
.field("filter", new String[]{"lowercase"})  
.endObject()  
.endObject()  
.startObject("analyzer")  
.startObject("email")  
.field("type", "custom")  
.field("tokenizer", "uax\_url\_email")  
.field("filter", new String[]{"standard","lowercase","stop"})  
.endObject()  
.endObject()  
.startObject("analyzer")  
.startObject("username")  
.field("type", "custom")  
.field("tokenizer", "username\_tokenizer")  
.field("filter", new String[]{"standard","lowercase"})  
.endObject()  
.endObject()  
.endObject()  
.endObject().string(), XContentType.JSON))  
.execute().actionGet();

I'm getting the following error:

Caused by: com.fasterxml.jackson.core.JsonParseException: Duplicate field 'analyzer'  
at [Source: {"analysis":{"tokenizer":{"username\_tokenizer":{"type":"nGram","min\_gram":1,"max\_gram":80}},"analyzer":{"string\_lowercase":{"type":"custom","tokenizer":"keyword","filter":["lowercase"]}},"analyzer":{"email":{"type":"custom","tokenizer":"uax\_url\_email","filter":["standard","lowercase","stop"]}},"analyzer":{"username":{"type":"custom","tokenizer":"username\_tokenizer","filter":["standard","lowercase"]}}}}; line: 1, column: 198]  
at com.fasterxml.jackson.core.json.JsonReadContext.\_checkDup(JsonReadContext.java:197) ~[jackson-core-2.6.2.jar:2.6.2]  
at com.fasterxml.jackson.core.json.JsonReadContext.setCurrentName(JsonReadContext.java:192) ~[jackson-core-2.6.2.jar:2.6.2]  
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:625) ~[jackson-core-2.6.2.jar:2.6.2]  
at org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:52) ~[elasticsearch-6.1.0.jar:6.1.0]  
at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:697) ~[elasticsearch-6.1.0.jar:6.1.0]  
at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:703) ~[elasticsearch-6.1.0.jar:6.1.0]  
at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:672) ~[elasticsearch-6.1.0.jar:6.1.0]  
at org.elasticsearch.common.settings.Settings.access$500(Settings.java:81) ~[elasticsearch-6.1.0.jar:6.1.0]  
at org.elasticsearch.common.settings.Settings$Builder.loadFromSource(Settings.java:1148) ~[elasticsearch-6.1.0.jar:6.1.0]

I suspect it may have something to do with creating multiple analyzers in the same JSON object. Is there a way to do this, or should I send each analyzer individually after creating the index? If so, what is the syntax to do this?

---

<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 29, 2018, 8:16pm UTC](https://discuss.elastic.co/t/issue-upgrading-from-2-3-1-to-6-1-0/117063/5 "2018-01-29T20:16:27Z")

</div>

Please open a new thread.

And format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```
````

---

<div class="post-metadata">

**Author:** ![Sam\_Schlaak](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@Sam\_Schlaak](https://discuss.elastic.co/u/Sam_Schlaak)\
**Post date:** [January 29, 2018, 8:20pm UTC](https://discuss.elastic.co/t/issue-upgrading-from-2-3-1-to-6-1-0/117063/6 "2018-01-29T20:20:56Z")

</div>

Apologies, I'm new to the forums here. I will open a new topic on this.

Thanks.

---

<div class="post-metadata">

**Author:** ![nj1892](https://avatars.discourse-cdn.com/v4/letter/n/43a26b/32.png) [@nj1892](https://discuss.elastic.co/u/nj1892)\
**Post date:** [February 5, 2018, 12:23pm UTC](https://discuss.elastic.co/t/issue-upgrading-from-2-3-1-to-6-1-0/117063/7 "2018-02-05T12:23:50Z")

</div>

I have same task at my hand can you tell me how are you planning on migrating data from es2.3 to es 6 ??

---

<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:** [March 5, 2018, 12:24pm UTC](https://discuss.elastic.co/t/issue-upgrading-from-2-3-1-to-6-1-0/117063/8 "2018-03-05T12:24:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
