Routing with Java Client UpdateRequests not working

Hey dear Elasticsearch community,
I would like to send an UpdateRequest with the Java REST Client (7.13) to Elasticsearch using the .routing() request parameter, because I am updating a join field. It seems, using this parameter does not take effect, as I still get a failure response with this error message:

Elasticsearch exception [type=illegal_argument_exception, reason=[routing] is missing for join field [email-attachment]]

The Java code I'm using for sending the request is as follows:

BulkRequest request = new BulkRequest();

// creating update object...

request.add(
    new UpdateRequest("index-002", id)
        .doc(updateObject.toString(), XContentType.JSON)
        .routing("1")
);

// creating action listener... 

request.routing("routing").timeout("1m");
client.client.bulkAsync(request, RequestOptions.DEFAULT, listener);

As you can see, I'm applying routing both to the update request and to the bulk request, but neither seems to do anything.

Note that running this request in the DevTools on the same index and data works, so the routing parameter should be correct:

POST index-002/_update/AXtZAYipjpoOf5DsXeDv?routing=1
{
  "doc": {
    "email-attachment": {
      "name": "attachment",
      "parent": "RtgEWXsBbfUU64dFU_Ei"
    }
  }
}

What am I doing wrong? Could the error message be inaccurate and the missing routing parameter is not the problem?

Thanks for any help, even with tips on where I could start debugging this. I'm at my wit's end.

So the usage of routing looks correct to me here. Can you share the full stack trace/HTTP response of that exception?

You can also increase logging and take a look what gets sent over there wire. That would be really useful to share as well (ensure that no credentials are in your snippets). See Logging | Java REST Client [7.14] | Elastic

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