# Update nested object using java client 6.5

**URL:** <https://discuss.elastic.co/t/update-nested-object-using-java-client-6-5/216874>\
**Category:** Elasticsearch\
**Created:** [January 28, 2020, 4:09pm UTC](https://discuss.elastic.co/t/update-nested-object-using-java-client-6-5/216874 "2020-01-28T16:09:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@Mohamed](https://discuss.elastic.co/u/Mohamed)\
**Post date:** [January 28, 2020, 4:09pm UTC](https://discuss.elastic.co/t/update-nested-object-using-java-client-6-5/216874/1 "2020-01-28T16:09:52Z")

</div>

Hello,

I want to update a nested object using java highlevel client.

My mapping looks like the following:

```
"reservations":{ 
               "type":"nested",
               "properties":{ 
                  "customerFullName":{ 
                     "type":"text"
                  },
                  "reservationStatus":{ 
                     "type":"text"
                  },
				  "quantity":{ 
                     "type":"double"
                  }				  
               }
            },

```

My java code is:

```
 UpdateByQueryRequest request = new UpdateByQueryRequest(ProductIndex.PRODUCT_INDEX);
		request.setQuery(QueryBuilders.matchPhraseQuery(ProductIndex.PROMOTION_REFERENCE, promotionReference));
		Map<String, Object> parameters = new HashMap<>();
		parameters.put(ProductIndex.RESERVATION_CUSTOMER_FULL_NAME, customerFullName);
		parameters.put(ProductIndex.RESERVATION_STATUS, ReservationStatus.NOT_DELIVERED);
		parameters.put(ProductIndex.RESERVATION_QUANTITY, quantity);

		request.setScript(new Script(ScriptType.INLINE, "painless", "ctx._source.reservations.add(params);", parameters));

		request.setScroll(TimeValue.timeValueMinutes(10));
		restHighLevelClient.updateByQuery(request, RequestOptions.DEFAULT);

```

The problem is ctx informations are added automatically to my object and I want to avoid it.  
After the update I have something like this:

```
reservations: [
               {
                  "customerFullName" : "customer name",
                  "quantity" : 2.0,
                  "reservationStatus" : "NOT_DELIVERED",
                  "ctx" : {
                    "_routing" : null,
                    "_parent" : null,
                    "_index" : "product_index",
                    "_type" : "product",
                    "_id" : "3QzW7G8BSs1v_UxEWpxw",
                    "_version" : 2
                   }
              }
]

```

So how can I avoid indexing ctx informations after the update.

Thanks!

---

<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:** [February 25, 2020, 4:10pm UTC](https://discuss.elastic.co/t/update-nested-object-using-java-client-6-5/216874/2 "2020-02-25T16:10:19Z")

</div>

Closed on February 25, 2020, 4:10pm UTC

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