# Java api bulk opreration

**URL:** <https://discuss.elastic.co/t/java-api-bulk-opreration/342659>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [September 9, 2023, 12:50pm UTC](https://discuss.elastic.co/t/java-api-bulk-opreration/342659 "2023-09-09T12:50:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zgy](https://avatars.discourse-cdn.com/v4/letter/z/858c86/32.png) [@zgy](https://discuss.elastic.co/u/zgy)\
**Post date:** [September 9, 2023, 12:50pm UTC](https://discuss.elastic.co/t/java-api-bulk-opreration/342659/1 "2023-09-09T12:50:42Z")

</div>

hello,I'm a student , and learning elasticsearch recently. when I use the java bulk api follow the official guides as [Bulk: indexing multiple documents | Elasticsearch Java API Client [8.3] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/8.3/indexing-bulk.html). but it's occured a error :

co.elastic.clients.elasticsearch.\_types.ElasticsearchException: [es/bulk] failed: [illegal\_argument\_exception] Malformed action/metadata line [3], expected START\_OBJECT but found [VALUE\_STRING]  
at co.elastic.clients.transport.rest\_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:282) ~[elasticsearch-java-8.5.1.jar:na]  
at co.elastic.clients.transport.rest\_client.RestClientTransport.performRequest(RestClientTransport.java:148) ~[elasticsearch-java-8.5.1.jar:na]  
at co.elastic.clients.elasticsearch.ElasticsearchClient.bulk(ElasticsearchClient.java:319) ~[elasticsearch-java-8.5.1.jar:na]

here is my code

my development environment is macos 10.14,es version is 8.5.2 and java 8.  
I don't how to resolve the problem.If you know please help me . and meanwhile I want to know how to use the bulk api to update and delete document.  
thanks.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 9, 2023, 3:17pm UTC](https://discuss.elastic.co/t/java-api-bulk-opreration/342659/2 "2023-09-09T15:17:52Z")

</div>

Welcome!

Hard to say as we can't see your code. Most likely your json content is wrong.  
Also please use the latest version 8.9.2.

---

<div class="post-metadata">

**Author:** ![zgy](https://avatars.discourse-cdn.com/v4/letter/z/858c86/32.png) [@zgy](https://discuss.elastic.co/u/zgy)\
**Post date:** [September 12, 2023, 2:04pm UTC](https://discuss.elastic.co/t/java-api-bulk-opreration/342659/4 "2023-09-12T14:04:31Z")

</div>

Thank you sir, I have solved the problem, It was my fault,I injected a wrong ObjectMapper into Spring bean Context, it deserialize my Object in a weird way.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 10, 2023, 2:04pm UTC](https://discuss.elastic.co/t/java-api-bulk-opreration/342659/5 "2023-10-10T14:04:58Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
