elastic / elasticsearch-java

Official Elasticsearch Java Client
Apache License 2.0
397 stars 228 forks source link

PutTemplateRequest - `Unknown field 'composed_of'` #814

Closed mdgilene closed 1 month ago

mdgilene commented 1 month ago

Java API client version

8.7.1

Java version

17

Elasticsearch Version

7.17.5

Problem description

Attempting to create a index template following the updated documentation recommending the usage of composable index templates with component templates. (https://www.elastic.co/guide/en/elasticsearch/reference/current/index-templates.html)

Caused by: co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch.indices.PutTemplateRequest: Unknown field 'composed_of'
client.indices()
    .putTemplate(
        r -> r.withJson(new StringReader("""
            {
                "composed_of": "my_component_template"
            }
            """))
            .name("my_index_template")
            .indexPatterns("prefix-*")

Note how I even had to use withJson to even set the composed_of property because there is no method for it.

l-trotta commented 1 month ago

Hello! Yes the api specification used to produce the java client code didn't match the server code perfectly for template requests up until recently when it was fixed with this PR; updating the client to the latest version should fix the issue.