Bulk + Update API

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(
                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?

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 ?

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.

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