Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from 8.13.4 to 8.14.1 break the dynamic template creation #841

Closed
TakiuGit opened this issue Jun 28, 2024 · 2 comments
Closed

Update from 8.13.4 to 8.14.1 break the dynamic template creation #841

TakiuGit opened this issue Jun 28, 2024 · 2 comments
Labels

Comments

@TakiuGit
Copy link

TakiuGit commented Jun 28, 2024

Java API client version

8.14.1

Java version

openjdk 11.0.21 2023-10-17 LTS

Elasticsearch Version

8.4.3

Problem description

Upgrading the driver from 8.13.4 to 8.14.1 I've come up with the following issue

Pushing to an ES server v8.4.3 introduce brackets in the "path_match" field in "dynamic_templates".
ex : from "titles.*" to "[titles.*]"
This is an actual breaking change as the template does not match anymore with the targeted fields names

Here is a minimal example to reproduce:

 public static void main(String[] args) throws IOException {
        RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)).build();
        ElasticsearchClient client = new ElasticsearchClient(
                    new RestClientTransport(restClient, new JacksonJsonpMapper()));

        Map<String, DynamicTemplate> value = Map.of("titles",
            new DynamicTemplate.Builder().pathMatch("titles.*")
                .mapping(new Property.Builder().text(new TextProperty.Builder().build()).build())
                .build());

        CreateIndexRequest indexRequest = new CreateIndexRequest.Builder().index("test_index")
            .mappings(new TypeMapping.Builder().dynamicTemplates(value).build())
            .build();
        client.indices().create(indexRequest);
    }

This is not reproducible with the server version 8.13.4, I've not tested with other versions.

@l-trotta
Copy link
Contributor

l-trotta commented Jul 1, 2024

Hello! The issue here is the server version 8.4.3, which doesn't allow multiple values for the dynamic templates pattern matching, a feature added around version 8.9 of the server. The clients are forward compatible only, meaning that we cannot guarantee compatibility with older versions of the server; in this particular case the problem lies with how the client simplifies parameters that can accept both a single string or arrays to just arrays. Updating the server to a more recent version should solve this.

@l-trotta l-trotta closed this as completed Jul 1, 2024
@TakiuGit
Copy link
Author

TakiuGit commented Jul 1, 2024

Hi @l-trotta, sorry for the trouble and thank's for your fast answer, I was not aware of the forward compatibility policy 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants