# Failed to put mappings on indices \[\[\[\]\]\], type \[string\] java.lang.IllegalArgumentException: Rejecting mapping update to \[\] as the final mapping would have more than 1 type: \[\_doc, string\]

**URL:** <https://discuss.elastic.co/t/failed-to-put-mappings-on-indices-type-string-java-lang-illegalargumentexception-rejecting-mapping-update-to-as-the-final-mapping-would-have-more-than-1-type-doc-string/229226>\
**Category:** Elasticsearch\
**Created:** [April 22, 2020, 10:05am UTC](https://discuss.elastic.co/t/failed-to-put-mappings-on-indices-type-string-java-lang-illegalargumentexception-rejecting-mapping-update-to-as-the-final-mapping-would-have-more-than-1-type-doc-string/229226 "2020-04-22T10:05:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacques\_van\_der\_Merw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jacques_van_der_merw/32/66851_2.png) [@Jacques\_van\_der\_Merw](https://discuss.elastic.co/u/Jacques_van_der_Merw)\
**Post date:** [April 22, 2020, 10:05am UTC](https://discuss.elastic.co/t/failed-to-put-mappings-on-indices-type-string-java-lang-illegalargumentexception-rejecting-mapping-update-to-as-the-final-mapping-would-have-more-than-1-type-doc-string/229226/1 "2020-04-22T10:05:05Z")

</div>

I am getting this error only when I define an Index template on Kibana. I define an index template in order to define a lifecylce policy.  
The error is "  
failed to put mappings on indices [[]], type [string]  
java.lang.IllegalArgumentException: Rejecting mapping update to as the final mapping would have more than 1 type: [\_doc, string]"

The index is auto created when first index is created, but as soon as the the data is loaded this error is thrown. I use Java Springboot to push the events to Elastic.

Here is extract of code

```auto
> private void sendToElasticSearch(WMQIStatisticsAccounting event) {
> String stringOut = "";
> // Local date time instance
> LocalDateTime localDateTime = LocalDateTime.now();
> 
> // Get formatted String
> String ldtString = localDateTime.format(indexDateFormatter);
> String elasticIndexName = indexName + "_" + ldtString;
> 
> ObjectMapper objectMapper = new ObjectMapper();
> WMQIStatisticsAccounting eventOut = setEventOut(event);
> 
> try {
> stringOut = objectMapper.writeValueAsString(eventOut);
> } catch (JsonProcessingException e2) {
> e2.printStackTrace();
> }
> 
> try {
> GetIndexRequest idexRequest = new GetIndexRequest();
> idexRequest.indices(elasticIndexName);
> 
> IndexRequest request = new IndexRequest(elasticIndexName);
> request.create(true);
> request.id(UUID.randomUUID().toString());
> request.type("string");
> request.opType(DocWriteRequest.OpType.CREATE);
> request.source(stringOut, XContentType.JSON);
> client.index(request, RequestOptions.DEFAULT);
> log.info("Id : " + request.id());
> } catch (Exception e) {
> throw new RuntimeException("Unable to push event to Elastic : " + e.getMessage());
> }
> }

```

I have read through all the previous comments that relates to this error and none are applicable.

---

<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:** [April 22, 2020, 11:23am UTC](https://discuss.elastic.co/t/failed-to-put-mappings-on-indices-type-string-java-lang-illegalargumentexception-rejecting-mapping-update-to-as-the-final-mapping-would-have-more-than-1-type-doc-string/229226/2 "2020-04-22T11:23:38Z")

</div>

This is your first post here. So welcome!

> [@Jacques\_van\_der\_Merw](#):
>
> please hold your sarcasm for another site

I'm not sure this comment adds anything.

Coming back to the question:

Change:

```
request.type("string");

```

To:

```
request.type("_doc");

```

This might help. Also have a look at this demo code I wrote. Might help:

> **[GitHub - dadoonet/elasticsearch-java-client-demo: Elasticsearch Client Java...](https://github.com/dadoonet/elasticsearch-java-client-demo)**
>
> Elasticsearch Client Java Sample project. Contribute to dadoonet/elasticsearch-java-client-demo development by creating an account on GitHub.

And here is a "full" project:

> <https://github.com/dadoonet/legacy-search/tree/06-fuzziness?files=1>
>
> //github.com/dadoonet/legacy-search/tree/06-fuzziness

---

<div class="post-metadata">

**Author:** ![Jacques\_van\_der\_Merw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jacques_van_der_merw/32/66851_2.png) [@Jacques\_van\_der\_Merw](https://discuss.elastic.co/u/Jacques_van_der_Merw)\
**Post date:** [April 22, 2020, 1:14pm UTC](https://discuss.elastic.co/t/failed-to-put-mappings-on-indices-type-string-java-lang-illegalargumentexception-rejecting-mapping-update-to-as-the-final-mapping-would-have-more-than-1-type-doc-string/229226/3 "2020-04-22T13:14:37Z")

</div>

> [@dadoonet](#):
>
> \_doc

Thanks, I have deployed this change and it assigned the lifecycle policy correctly and no longer gave the error in initial post.

---

<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:** [May 20, 2020, 1:14pm UTC](https://discuss.elastic.co/t/failed-to-put-mappings-on-indices-type-string-java-lang-illegalargumentexception-rejecting-mapping-update-to-as-the-final-mapping-would-have-more-than-1-type-doc-string/229226/4 "2020-05-20T13:14:53Z")

</div>

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