# Java API updating index templates: script parse exception

**URL:** <https://discuss.elastic.co/t/java-api-updating-index-templates-script-parse-exception/37292>\
**Category:** Elasticsearch\
**Created:** [December 16, 2015, 1:58am UTC](https://discuss.elastic.co/t/java-api-updating-index-templates-script-parse-exception/37292 "2015-12-16T01:58:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![featheredtoast](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/featheredtoast/32/6627_2.png) [@featheredtoast](https://discuss.elastic.co/u/featheredtoast)\
**Post date:** [December 16, 2015, 1:58am UTC](https://discuss.elastic.co/t/java-api-updating-index-templates-script-parse-exception/37292/1 "2015-12-16T01:58:56Z")

</div>

Hi there,

Looking for some pointers or tips for upgrading elasticsearch. Currently under 1.4. I've been reading about the changes to mappings and the java API to upgrade to 2.1.

I'm following the conventions for sending the templates via the HTTP api to construct the source here:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html)

Everything works when I send the generated string to the server directly. However, using the java API, I'm getting a strange exception with the same string:

`ScriptParseException[unexpected field [settings]]`

The java docs to update a template isn't very verbose. Am I missing something?

Following [https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/indexed-scripts.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/indexed-scripts.html)  
using "mustache" for the scriptlang as suggested there.

EDIT:

I was using the wrong functions. I copied from ES's test examples here. Was confused between 'scripts' and 'templates' as it's not entirely clear at first glance in the docs.

> <https://github.com/elastic/elasticsearch/blob/d78e24689b085992f626da30c078f4e9a5cf286f/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java#L188>

---

<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 5, 2017, 11:30pm UTC](https://discuss.elastic.co/t/java-api-updating-index-templates-script-parse-exception/37292/2 "2017-07-05T23:30:27Z")

</div>


