# Manipulate source data using script

**URL:** <https://discuss.elastic.co/t/manipulate-source-data-using-script/196434>\
**Category:** Elasticsearch\
**Created:** [August 23, 2019, 3:40am UTC](https://discuss.elastic.co/t/manipulate-source-data-using-script/196434 "2019-08-23T03:40:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmunnur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmunnur/32/45283_2.png) [@rmunnur](https://discuss.elastic.co/u/rmunnur)\
**Post date:** [August 23, 2019, 3:40am UTC](https://discuss.elastic.co/t/manipulate-source-data-using-script/196434/1 "2019-08-23T03:40:59Z")

</div>

Hi All,

I want to check if there is a way to manipulate the response returned by elasticsearch.  
For ex: Below is the response and I would like replace the docdate field value based on user time zone. I don't want it as separate script fields.

{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 3,  
"successful" : 3,  
"skipped" : 0,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : null,  
"hits" : [  
{  
"\_source" : {  
"dateaccepted" : "0001-01-01T00:00:00",  
"datecreated" : "2019-08-22T15:10:45",  
"docdate" : "2019-08-22T15:50:05.577",  
}  
}  
]  
}  
}

---

<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 23, 2019, 7:13am UTC](https://discuss.elastic.co/t/manipulate-source-data-using-script/196434/2 "2019-08-23T07:13:22Z")

</div>

The `_source` is always the exact data that has been inserted when storing the document, it is not modified.

---

<div class="post-metadata">

**Author:** ![rmunnur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmunnur/32/45283_2.png) [@rmunnur](https://discuss.elastic.co/u/rmunnur)\
**Post date:** [August 23, 2019, 4:32pm UTC](https://discuss.elastic.co/t/manipulate-source-data-using-script/196434/3 "2019-08-23T16:32:42Z")

</div>

Thanks Alexander!

---

<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 20, 2019, 4:32pm UTC](https://discuss.elastic.co/t/manipulate-source-data-using-script/196434/4 "2019-09-20T16:32:43Z")

</div>

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