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!