# When using UpdateByQuery it appears the return json for \_source is modified and fields are returned out of order

**URL:** https://discuss.elastic.co/t/when-using-updatebyquery-it-appears-the-return-json-for-source-is-modified-and-fields-are-returned-out-of-order/234840
**Category:** Elasticsearch
**Created:** [May 29, 2020, 12:37am UTC](https://discuss.elastic.co/t/when-using-updatebyquery-it-appears-the-return-json-for-source-is-modified-and-fields-are-returned-out-of-order/234840 "2020-05-29T00:37:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![skv325](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@skv325](https://discuss.elastic.co/u/skv325)
#### Post date: [May 29, 2020, 12:37am UTC](https://discuss.elastic.co/t/when-using-updatebyquery-it-appears-the-return-json-for-source-is-modified-and-fields-are-returned-out-of-order/234840/1 "2020-05-29T00:37:19Z")

</div>

Hi,  
I have an issue with using C# NEST low level client UpdateByQuery method. When I update index documents with this method, properties in \_source get shuffled. Fields are returned out of order for the updated documents in Kibana UI.  
Is any way to preserve order of fields in \_source after update?  
Thanks

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [May 29, 2020, 4:26am UTC](https://discuss.elastic.co/t/when-using-updatebyquery-it-appears-the-return-json-for-source-is-modified-and-fields-are-returned-out-of-order/234840/2 "2020-05-29T04:26:40Z")

</div>

JSON serializers typically do not guarantee any specific ordering, so if you e.g. perform an update by query with a script, the document need to be parsed and then modified before being serialized back to JSON. Given that fields could be added and/or removed I do not think order can be guaranteed.

---

<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: [June 26, 2020, 4:26am UTC](https://discuss.elastic.co/t/when-using-updatebyquery-it-appears-the-return-json-for-source-is-modified-and-fields-are-returned-out-of-order/234840/3 "2020-06-26T04:26:51Z")

</div>

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