Skip to content

Cannot create index with mappings settings #297

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

Closed
jaizpuru opened this issue May 28, 2022 · 6 comments
Closed

Cannot create index with mappings settings #297

jaizpuru opened this issue May 28, 2022 · 6 comments
Labels
Area: Specification Related to the API spec used to generate client code

Comments

@jaizpuru
Copy link

Java API client version

8.2.2

Java version

8

Elasticsearch Version

8.2.2

Problem description

The following code is expected to trigger an index creation in the target server. Instead, the error response below is received

RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)).build();
ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());

CreateIndexRequest request = new CreateIndexRequest.Builder().index("name")
    .settings(s -> s.mappings(m -> m.totalFields(totalFields -> totalFields.limit(1001))))
    .build();

new ElasticsearchClient(transport).indices().create(request);

Response:

[es/indices.create] failed: [illegal_argument_exception] unknown setting [index.mappings.total_fields.limit] did you mean any of ...

@KnowledgeGarden
Copy link

In earlier versions, there was a clean api with which to load JSON mappings. It's gone and, post 7, no documentation. Surely there is a way to load JSON mappings in recent versions.

@yoh1496
Copy link

yoh1496 commented Jun 13, 2022

Hi, I have same problem.
It is written in below document that mapping limit settings should place with parameter index.mapping.*

https://www.elastic.co/guide/en/elasticsearch/reference/8.2/mapping-settings-limit.html

So, this line should be change like this.

https://github.com/elastic/elasticsearch-java/blob/main/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexSettings.java#L1997

op.add(Builder::mappings, MappingLimitSettings._DESERIALIZER, "mapping");

Could you change this?

@yoh1496
Copy link

yoh1496 commented Jun 21, 2022

Hi, @swallez .
Could you check this issue? If you already checked, I apologize about my impoliteness.

I think this issue and one of #295 are api-spec problem in IndexSettings. And I hope this issue will be resolved in next release.

@swallez swallez added the Area: Specification Related to the API spec used to generate client code label Jun 23, 2022
@swallez
Copy link
Member

swallez commented Jun 23, 2022

This is an issue in the API specification used to produce the Java code: mappings should be mapping.

The fix will be included in the next 8.x and 7.17.x releases.

@swallez
Copy link
Member

swallez commented Jun 23, 2022

@KnowledgeGarden

In earlier versions, there was a clean api with which to load JSON mappings. It's gone and, post 7, no documentation. Surely there is a way to load JSON mappings in recent versions.

There is indeed a way to load JSON mappings. It's not limited to mappings actually, and can be used with API object. Please see explanation and examples at https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/loading-json.html

@swallez
Copy link
Member

swallez commented Jun 23, 2022

Closing, as the same issue has been reported in #295

@swallez swallez closed this as completed Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Specification Related to the API spec used to generate client code
Projects
None yet
Development

No branches or pull requests

4 participants