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

Missing support for script in field mapping Property objects #690

Closed
c-dante opened this issue Oct 16, 2023 · 1 comment · Fixed by #815
Closed

Missing support for script in field mapping Property objects #690

c-dante opened this issue Oct 16, 2023 · 1 comment · Fixed by #815
Labels
Area: Specification Related to the API spec used to generate client code

Comments

@c-dante
Copy link

c-dante commented Oct 16, 2023

Java API client version

7.17.10

Java version

17

Elasticsearch Version

7.17.1

Problem description

The Property object does not support the script field for mapping types, e.g. keyword or date:

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/keyword.html

script If this parameter is set, then the field will index values generated by this script, rather than reading the values directly from the source. If a value is set for this field on the input document, then the document will be rejected with an error. Scripts are in the same format as their runtime equivalent. Values emitted by the script are normalized as usual, and will be ignored if they are longer that the value set on ignore_above.

I would expect something like this snippet to work:

String mapping = """
{
  "properties": {
    "foo": {
      "type": "keyword",
      "script": "emit(params['_source']['id'].substring(0, 10))"
    }
  }
}
""";

client
  .indices()
  .create(cb -> cb.mappings(mb -> mb.withJson(new StringReader(mapping)))

And looking at the docs, there are a LOT of missing fields -- IMHO, an architecture change that allows overriding or providing additional arbitrary Map<String, Json> to overlay on any of the JsonP shapes would go a LONG way to allow working around all these shortcomings :|

@c-dante c-dante changed the title Missing support for script field mappings Missing support for script in field mapping Property objects Oct 17, 2023
@l-trotta
Copy link
Contributor

Hello, thanks for the report! Yes there seem to be some missing fields around property types, it's a problem within the API specification used to produce the Java code. We'll update it and regenerate the client code to fix this.

@l-trotta l-trotta added the Area: Specification Related to the API spec used to generate client code label Apr 24, 2024
This was referenced May 28, 2024
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

Successfully merging a pull request may close this issue.

2 participants