# Routing with Java Client UpdateRequests not working

**URL:** <https://discuss.elastic.co/t/routing-with-java-client-updaterequests-not-working/281819>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [August 18, 2021, 12:45pm UTC](https://discuss.elastic.co/t/routing-with-java-client-updaterequests-not-working/281819 "2021-08-18T12:45:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![redbow](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@redbow](https://discuss.elastic.co/u/redbow)\
**Post date:** [August 18, 2021, 12:45pm UTC](https://discuss.elastic.co/t/routing-with-java-client-updaterequests-not-working/281819/1 "2021-08-18T12:45:13Z")

</div>

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:

```auto
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:

```java
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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 25, 2021, 10:09am UTC](https://discuss.elastic.co/t/routing-with-java-client-updaterequests-not-working/281819/2 "2021-08-25T10:09:10Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.14/java-rest-low-usage-logging.html)

---

<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:** [September 22, 2021, 10:09am UTC](https://discuss.elastic.co/t/routing-with-java-client-updaterequests-not-working/281819/3 "2021-09-22T10:09:53Z")

</div>

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