Skip to content

[Documentation] Document how to use the CreateIndexRequest, particularly the mappings #208

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
cyrille-leclerc opened this issue Mar 18, 2022 · 2 comments
Labels
Area: Specification Related to the API spec used to generate client code

Comments

@cyrille-leclerc
Copy link

cyrille-leclerc commented Mar 18, 2022

Description

Could you please provide an example on how to use the CreateIndexRequest API, particularly how to define the mappings?

I didn't catch how to use the CreateIndexRequest.Builder#mappings() API to do something like

PUT /logs
{"mappings": {
    "properties": {
      "@timestamp": { "type": "date" },
      "message": { "type": "match_only_text" }
    }
  }
}
@swallez
Copy link
Member

swallez commented Mar 18, 2022

Good catch, match_only_text is missing from the API specification. I opened elastic/elasticsearch-specification#1548 to fix this.

If you use text instead, that would be:

client.indices().create(r -> r
    .index("logs")
    .mappings(m -> m
        .properties("@timestamp", p -> p.date(d -> d))
        .properties("message", p -> p.text(t -> t))
    )
);

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

swallez commented May 23, 2022

This has been fixed in the API specification in elastic/elasticsearch-specification#1549 and in the Java client in 2b5f3d2.

@swallez swallez closed this as completed May 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

2 participants