# Painless: problem accessing nested object using dot notation

**URL:** <https://discuss.elastic.co/t/painless-problem-accessing-nested-object-using-dot-notation/150599>\
**Category:** Elasticsearch\
**Created:** [October 1, 2018, 6:55pm UTC](https://discuss.elastic.co/t/painless-problem-accessing-nested-object-using-dot-notation/150599 "2018-10-01T18:55:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [October 3, 2018, 11:35pm UTC](https://discuss.elastic.co/t/painless-problem-accessing-nested-object-using-dot-notation/150599/2 "2018-10-03T23:35:06Z")

</div>

It looks like `ctx._source.context` is an array in your source. So you need to iterate through each value of the array and dereference it by index. So instead of `ctx._source.context.data`, you need a loop like:

```auto
for (int i = 0; i < ctx._source.context.length; ++i) {
  ctx._source.context[i].data
}

```

---

_[View the full topic](https://discuss.elastic.co/t/painless-problem-accessing-nested-object-using-dot-notation/150599)._
