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

RemoveProcessor deserializer doesn't support "keep" field #610

Closed
borowis opened this issue Jun 27, 2023 · 1 comment · Fixed by #800
Closed

RemoveProcessor deserializer doesn't support "keep" field #610

borowis opened this issue Jun 27, 2023 · 1 comment · Fixed by #800
Labels
Area: Specification Related to the API spec used to generate client code

Comments

@borowis
Copy link

borowis commented Jun 27, 2023

Java API client version

8.7.0

Java version

17

Elasticsearch Version

8.5.2

Problem description

Given following pipeline definition:

{
  "description": "test",
  "processors": [
    {
      "remove": {
        "keep": ["properties", "firstName", "lastName"],
        "description": "Remove the fields other than expected (please also see index-definition)"
      }
    }
  ]
}

We do:

<dataFile>.getInputStream().bufferedReader().use { bufferedReader ->
            val objectMapper = jacksonObjectMapper()
            val dataTransformationDefinition = objectMapper.readValue<Map<String, Any>>(bufferedReader)

            val processorList = dataTransformationDefinition["processors"] as List<*>

            val processors = processorList
                .map { processor -> objectMapper.writeValueAsString(processor) }
                .map { processorJson ->
                    Processor.Builder().withJson(processorJson.byteInputStream()).build()
                }

            // create ingest pipeline via Elasticsearch client and PutPipelineRequest
        }

But this fails with:

Original Stack Trace:
at co.elastic.clients.json.ObjectDeserializer.parseUnknownField(ObjectDeserializer.java:233)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:190)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:148)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:77)
at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:79)
at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43)
at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:78)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:192)
at co.elastic.clients.util.WithJsonObjectBuilderBase.withJson(WithJsonObjectBuilderBase.java:54)
at co.elastic.clients.json.WithJson.withJson(WithJson.java:43)

The reason is that the keep field is not present in RemoveProcessor deserializer

protected static void setupRemoveProcessorDeserializer(ObjectDeserializer<RemoveProcessor.Builder> op) {
although it apparently should be supported via API https://www.elastic.co/guide/en/elasticsearch/reference/8.5/remove-processor.html

@l-trotta
Copy link
Contributor

Hello, thanks for reporting this! It's an issue in the API specification used to produce the Java code, we'll fix this and then regenerate the code to solve the issue.

@l-trotta l-trotta added the Area: Specification Related to the API spec used to generate client code label Apr 18, 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