I'm having trouble doing a bulk index request using the java 8.1.1 client. I get an unclear error message and I'm basically stuck.
String test= "{ \"test\",\"test\"}";
final InputStream jsonInputStream = new ByteArrayInputStream(test.getBytes());
final ElasticsearchClient client = instanceManager.getClient();
final BulkResponse response = client.bulk(br -> br.operations(
bo -> bo.index(io -> io.withJson(jsonInputStream).index("test").id("1"))
));
I get the following cryptic error upon execution:
java.lang.IllegalArgumentException: Class class co.elastic.clients.elasticsearch.core.bulk.IndexOperation cannot be read from JSON
at co.elastic.clients.util.WithJsonObjectBuilderBase.withJson(WithJsonObjectBuilderBase.java:46)
at co.elastic.clients.json.WithJson.withJson(WithJson.java:43)
...
I assume that there is something wrong with my json, but the documentation unfortunately doesn't list a java example.
Can someone please help in providing a working example?
I saw that the error occurs because the mapper doesn't deserialize the class because it doesn't have the @JsonpDeserializable annotation.
Maybe you have to mount an object instead of reading a json.
There is no 'Product' builder in the 8.1.1 API it seems, what import are you using?
In my particular case; I'm getting json files delivered which represent a document, but it would mean I'd have to parse them and rebuild them using the builder.
Dear, I'm facing the same error while trying to index a JSON with withJson method. I tried to use RawValue but still having an error when sending the request to the server:
co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/bulk] failed: [illegal_argument_exception] Malformed action/metadata line [3], expected START_OBJECT but found [VALUE_STRING]
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.