# Updating object field using \_reindex API script not working

**URL:** <https://discuss.elastic.co/t/updating-object-field-using-reindex-api-script-not-working/167653>\
**Category:** Elasticsearch\
**Created:** [February 8, 2019, 3:18pm UTC](https://discuss.elastic.co/t/updating-object-field-using-reindex-api-script-not-working/167653 "2019-02-08T15:18:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahulkothanath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahulkothanath/32/99122_2.png) [@rahulkothanath](https://discuss.elastic.co/u/rahulkothanath)\
**Post date:** [February 8, 2019, 3:18pm UTC](https://discuss.elastic.co/t/updating-object-field-using-reindex-api-script-not-working/167653/1 "2019-02-08T15:18:34Z")

</div>

I am trying to reindex an index and trying to create new field from two object fields.  
I am not able to access the field value latitude and it is returning null.

code below  
POST \_reindex  
{  
"source": {  
"index": "append7"  
},  
"dest": {  
"index": "append8"  
},  
"script": {  
"source": "ctx.\_source['NEW'] = ctx.\_source['a.b.latitude'] + ',' + ctx.\_source['a.b.longitude]",  
"lang": "painless"  
}  
}

My \_source shows like this:  
"a":{  
"b":{  
"latitude":"42.00",  
"longitude":"74.32"  
}

}

---

<div class="post-metadata">

**Author:** ![celikbaris61](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@celikbaris61](https://discuss.elastic.co/u/celikbaris61)\
**Post date:** [February 8, 2019, 10:19pm UTC](https://discuss.elastic.co/t/updating-object-field-using-reindex-api-script-not-working/167653/2 "2019-02-08T22:19:53Z")

</div>

Hi,

What's your ES release ?

---

<div class="post-metadata">

**Author:** ![rahulkothanath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahulkothanath/32/99122_2.png) [@rahulkothanath](https://discuss.elastic.co/u/rahulkothanath)\
**Post date:** [February 19, 2019, 1:17am UTC](https://discuss.elastic.co/t/updating-object-field-using-reindex-api-script-not-working/167653/3 "2019-02-19T01:17:48Z")

</div>

I am using elastic search 6.3.1 .  
I was able to access the field using the below method but don't know why ". " operatror not working on inner object fields.

```
"script": {
"source": """ctx._source['location_config'] = ctx._source.a.get('Response._latitude')+ ',' + ctx._source.a.get('Response._longitude')""",

"lang": "painless"
}`Preformatted text`
```

---

<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:** [March 19, 2019, 1:17am UTC](https://discuss.elastic.co/t/updating-object-field-using-reindex-api-script-not-working/167653/4 "2019-03-19T01:17:55Z")

</div>

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