# It is a 404 respones when query a index template which is not exist

**URL:** https://discuss.elastic.co/t/it-is-a-404-respones-when-query-a-index-template-which-is-not-exist/152386
**Category:** Elasticsearch
**Created:** [October 14, 2018, 1:14pm UTC](https://discuss.elastic.co/t/it-is-a-404-respones-when-query-a-index-template-which-is-not-exist/152386 "2018-10-14T13:14:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dongming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dongming/32/36522_2.png) [@dongming](https://discuss.elastic.co/u/dongming)
#### Post date: [October 14, 2018, 1:14pm UTC](https://discuss.elastic.co/t/it-is-a-404-respones-when-query-a-index-template-which-is-not-exist/152386/1 "2018-10-14T13:14:42Z")

</div>

hi, i am using elasticsearch 6.4.0, when i start my application , i wanna firstly query whether the template exist or not. if it is not exits i will create it .

so when i use the high level client , the code as follows:

```java
        GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest("abc");
        GetIndexTemplatesResponse response =
            highLevelClient.indices().getTemplate(getIndexTemplatesRequest, RequestOptions.DEFAULT);
        if (response.getIndexTemplates().stream().filter(e -> e.getName().equals("abc")).count() != 0)
        {
            //如果template存在则不创建
            runLogger.info("index template {} is exist,no need to create template", "abc");
            return;
        }

```

so , when it will get the error message like this:

```auto
Caused by: org.elasticsearch.ElasticsearchStatusException: Unable to parse response body
        at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1386) ~[elasticsearch-rest-high-level-client-6.4.0.jar:6.4.0]
        at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1269) ~[elasticsearch-rest-high-level-client-6.4.0.jar:6.4.0]
        at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1231) ~[elasticsearch-rest-high-level-client-6.4.0.jar:6.4.0]
        at org.elasticsearch.client.IndicesClient.getTemplate(IndicesClient.java:1228) ~[elasticsearch-rest-high-level-client-6.4.0.jar:6.4.0]

```

when i first setting the template by curl commad ,it will be ok

so , my question is why this happen when there is no template, or just design to do so.

can anyone give some help..

---

<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: [October 14, 2018, 2:16pm UTC](https://discuss.elastic.co/t/it-is-a-404-respones-when-query-a-index-template-which-is-not-exist/152386/2 "2018-10-14T14:16:16Z")

</div>

Could you try with 6.4.2 and if you can still reproduce open an issue in GitHub?

---

<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: [November 11, 2018, 2:16pm UTC](https://discuss.elastic.co/t/it-is-a-404-respones-when-query-a-index-template-which-is-not-exist/152386/3 "2018-11-11T14:16:19Z")

</div>

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