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

(Dongming) #1

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:

        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)
  "index template {} is exist,no need to create template", "abc");

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

Caused by: org.elasticsearch.ElasticsearchStatusException: Unable to parse response body
        at org.elasticsearch.client.RestHighLevelClient.parseResponseException( ~[elasticsearch-rest-high-level-client-6.4.0.jar:6.4.0]
        at org.elasticsearch.client.RestHighLevelClient.performRequest( ~[elasticsearch-rest-high-level-client-6.4.0.jar:6.4.0]
        at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity( ~[elasticsearch-rest-high-level-client-6.4.0.jar:6.4.0]
        at org.elasticsearch.client.IndicesClient.getTemplate( ~[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..

(David Pilato) #2

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

(system) #3

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