# How to access the \_index object through painless inline

**URL:** <https://discuss.elastic.co/t/how-to-access-the--index-object-through-painless-inline/80584>\
**Category:** Elasticsearch\
**Created:** [March 30, 2017, 4:59am UTC](https://discuss.elastic.co/t/how-to-access-the--index-object-through-painless-inline/80584 "2017-03-30T04:59:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chembo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chembo/32/16907_2.png) [@chembo](https://discuss.elastic.co/u/chembo)\
**Post date:** [March 30, 2017, 4:59am UTC](https://discuss.elastic.co/t/how-to-access-the--index-object-through-painless-inline/80584/1 "2017-03-30T04:59:00Z")

</div>

i need the POSITIONS info, it's ok to get it by the groovy language:

```json
"script": {
        "inline": "def s = 0;termInfo=_index['goods_name_separate'].get('book',_POSITIONS| _CACHE);for(pos in termInfo){s++; break;}; return s;",
        "lang": "groovy"
      }

```

but how to access the \_index object through painless and java?  
i got compile error when turning lang to painess.  
i am using 5.1.2.

---

<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:** [April 27, 2017, 4:59am UTC](https://discuss.elastic.co/t/how-to-access-the--index-object-through-painless-inline/80584/2 "2017-04-27T04:59:02Z")

</div>

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