elasticsearch-java icon indicating copy to clipboard operation
elasticsearch-java copied to clipboard

java.lang.IllegalArgumentException: Class class co.elastic.clients.elasticsearch.core.bulk.UpdateOperation cannot be read from JSON

Open lucky-xin opened this issue 2 years ago • 2 comments

Java API client version

8.5.3 and 8.4.1

Java version

jdk11

Elasticsearch Version

8.4.1

Problem description

java.lang.IllegalArgumentException: Class class co.elastic.clients.elasticsearch.core.bulk.UpdateOperation cannot be read from JSON

StringReader reader = new StringReader(json);
            BulkOperation updateOp = new BulkOperation.Builder()
                            .update(new UpdateOperation.Builder<>()
                            .index(topic)
                            .id("1")
                            .withJson(reader)
                            .retryOnConflict(Math.min(1, 5))
                            .build())
                    .build();

image image

lucky-xin avatar Jan 04 '23 14:01 lucky-xin

@lucky-xin did you find a solution to this?

yash-meesho avatar Jan 11 '23 13:01 yash-meesho

Would it be possible to add the implementation for .withJson on the UpdateOperation?

I have a pre-serialized JSON as well that I'd want to pass to my UpdateOperation but neither .withJson works nor using .action(UpdateAction.of(ua -> ua.doc(BinaryData.of(jsonBytes, contentType)))

os-cas avatar May 17 '24 13:05 os-cas