# PutIndexTemplateRequest problem using JSON as source - mappings fail to parse

**URL:** <https://discuss.elastic.co/t/putindextemplaterequest-problem-using-json-as-source-mappings-fail-to-parse/224803>\
**Category:** Elasticsearch\
**Created:** [March 24, 2020, 10:29am UTC](https://discuss.elastic.co/t/putindextemplaterequest-problem-using-json-as-source-mappings-fail-to-parse/224803 "2020-03-24T10:29:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Samo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_samo/32/46830_2.png) [@Chris\_Samo](https://discuss.elastic.co/u/Chris_Samo)\
**Post date:** [March 24, 2020, 10:29am UTC](https://discuss.elastic.co/t/putindextemplaterequest-problem-using-json-as-source-mappings-fail-to-parse/224803/1 "2020-03-24T10:29:26Z")

</div>

I'm trying to use the Elasticsearch Java SDK (7.6.0) to validate some index template JSON that I know works when sent to Elasticsearch's `_template` endpoint through Kibana/direct to the Elasticsearch instance.

Example template JSON:

```json
{
    "order": 1,
    "index_patterns": [
        "organisations"
    ],
    "mappings": {
        "properties": {
            "organisation_name": {
                "type": "text",
                "fields": {
                    "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                    }
                }
            }
        }
    }
}

```

Example code:

```java
public class IndexTemplatesTest extends ESSingleNodeTestCase {
    public void testTemplateIsLoaded() throws IOException {
        // clean all templates setup by the framework.
        client().admin().indices().prepareDeleteTemplate("*").get();

        // setup Template request for the JSON file
        final PutIndexTemplateRequest template = new PutIndexTemplateRequest(templateDetails.getName());
        final InputStream jsonIs = FileSystemUtils.openFileURLStream(
                Objects.requireNonNull(getClass().getClassLoader().getResource("my-template.json"))
        );
        final byte[] bytes = new byte[jsonIs.available()];
        template.source(bytes, XContentType.JSON);

        // FIXME: the template creation fails because Elasticsearch thinks the "mappings" are invalid, although the same content works fine via Kibana?
        final ActionFuture<AcknowledgedResponse> templateResponse = client().admin().indices().putTemplate(template);
        assertTrue(templateResponse.actionGet().isAcknowledged());
  }
}

```

Exception received:  
`MapperParsingException[Failed to parse mapping [properties]: Root mapping definition has unsupported parameters: [organisation_name : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] ]; nested: MapperParsingException[Root mapping definition has unsupported parameters: [organisation_name : {type=text, fields={keyword={ignore_above=256, type=keyword}}}]];`

Which is thrown by:  
`at org.elasticsearch.index.mapper.DocumentMapperParser.checkNoRemainingFields(DocumentMapperParser.java:148)`

What am I doing wrong? Should I be able to test my template JSON using this kind of approach or is this completely wrong? (Basically I'm looking for a way to ensure anyone updating the template JSON at least does so in such a way that it's still valid JSON and would be accepted by Elasticsearch, without necessarily having to push it to a running Elasticsearch instance/cluster)

---

<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:** [April 21, 2020, 10:29am UTC](https://discuss.elastic.co/t/putindextemplaterequest-problem-using-json-as-source-mappings-fail-to-parse/224803/2 "2020-04-21T10:29:27Z")

</div>

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