# Script access to nested field

**URL:** <https://discuss.elastic.co/t/script-access-to-nested-field/329860>\
**Category:** Elasticsearch\
**Created:** [April 12, 2023, 4:42pm UTC](https://discuss.elastic.co/t/script-access-to-nested-field/329860 "2023-04-12T16:42:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GR8](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gr8/32/119744_2.png) [@GR8](https://discuss.elastic.co/u/GR8)\
**Post date:** [April 12, 2023, 4:42pm UTC](https://discuss.elastic.co/t/script-access-to-nested-field/329860/1 "2023-04-12T16:42:02Z")

</div>

Hello Elastic folks,

I need to run a script that gets data from _index\_a_ to _index\_b_ with some basic ETL.

This works well except I can't figure out the syntax for accessing a nested field like:

```auto
"transitions": {
  "properties": {
    "channel": {
      "type": "keyword"
    },
    "created_at": {
      "format": "epoch_millis",
      "type": "date"
    },

```

My `_reindex` script looks like this:

```auto
if (ctx._source.transitions != null && ctx._source.transitions.created_at != null) {
  ctx._source.transitions.created_at =
    ctx._source.transitions.created_at / 1000000;
}

```

…and returns the error

```auto
     "script_stack" : [
      "if(ctx._source.transitions!=null&&ctx._source.transitions.created_at!=null){",
      " ^---- HERE"
    ],
…
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "Illegal list shortcut value [created_at]."

```

It feels like I'm missing something obvious.

Thanks for your help!

---

<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:** [May 10, 2023, 4:42pm UTC](https://discuss.elastic.co/t/script-access-to-nested-field/329860/2 "2023-05-10T16:42:44Z")

</div>

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