# Bulk + Update API

**URL:** <https://discuss.elastic.co/t/bulk-update-api/140338>\
**Category:** Elasticsearch\
**Created:** [July 17, 2018, 1:55pm UTC](https://discuss.elastic.co/t/bulk-update-api/140338 "2018-07-17T13:55:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Varan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varan/32/32120_2.png) [@Varan](https://discuss.elastic.co/u/Varan)\
**Post date:** [July 17, 2018, 1:55pm UTC](https://discuss.elastic.co/t/bulk-update-api/140338/1 "2018-07-17T13:55:37Z")

</div>

Hi, I have some trouble making my bulk-update API work.  
I have Elasticsearch **6.2**.

So here the SQL request:

```
String sqlBulk = "SELECT id "
        + "from table tab "
        + "ORDER BY tab.ID ASC LIMIT ? ";
PreparedStatement preparedStatement = connection.prepareStatement(sqlBulk);
preparedStatement.setInt(1, 1);
ResultSet reSet = preparedStatement.executeQuery();

```

And there the connection to ES, creation of the bulk and the map.

```
  RestHighLevelClient client = new RestHighLevelClient(
        RestClient.builder(
                new org.apache.http.HttpHost("localhost", 9200, "http")));

BulkRequest request = new BulkRequest();

while (reSet.next()) {

Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("comment", "daily update");
jsonMap.put("the_id", reSet.getString("tab.id"));

request.add(new UpdateRequest("entite", "doc","101") 
         .doc(jsonMap, XContentType.JSON));

}

```

And here's when the bulk is supposed to be sent.

`BulkResponse bulkResponse = client.bulk(request);`

It supposed to update one document (the **101** ) with the field **comment** (with the string "daily update") and the field **the\_id** (with the id found).

The program run but nothing get updated. Do you have any ideas?

---

<div class="post-metadata">

**Author:** ![Varan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varan/32/32120_2.png) [@Varan](https://discuss.elastic.co/u/Varan)\
**Post date:** [July 18, 2018, 3:41pm UTC](https://discuss.elastic.co/t/bulk-update-api/140338/2 "2018-07-18T15:41:52Z")

</div>

I should add that I've managed to make the **Bulk-Index API** working properly and the **Update API** as well.

But for the amount of data that I have, I must use the **Bulk API** with the **Update** one.

Let me know if I'm not clear enough somewhere.

The question is: **How do you manage to make the UpdateRequest work in a BulkRequest ?**

---

<div class="post-metadata">

**Author:** ![Varan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varan/32/32120_2.png) [@Varan](https://discuss.elastic.co/u/Varan)\
**Post date:** [July 19, 2018, 9:27am UTC](https://discuss.elastic.co/t/bulk-update-api/140338/3 "2018-07-19T09:27:02Z")

</div>

Ok. It seem like the problem was that the mapping type simply should have been "\_doc" instead of "doc".

I don't know why the documentation advise for one at some point and the other later on.

---

<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:** [August 16, 2018, 9:27am UTC](https://discuss.elastic.co/t/bulk-update-api/140338/4 "2018-08-16T09:27:02Z")

</div>

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