# Accessing \_index variable inside painless script?

**URL:** <https://discuss.elastic.co/t/accessing--index-variable-inside-painless-script/82362>\
**Category:** Elasticsearch\
**Created:** [April 13, 2017, 10:22pm UTC](https://discuss.elastic.co/t/accessing--index-variable-inside-painless-script/82362 "2017-04-13T22:22:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![olalonde](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olalonde/32/17118_2.png) [@olalonde](https://discuss.elastic.co/u/olalonde)\
**Post date:** [April 13, 2017, 10:27pm UTC](https://discuss.elastic.co/t/accessing--index-variable-inside-painless-script/82362/2 "2017-04-13T22:27:12Z")

</div>

So it seems \_index is no longer accessible from painless scripts:

> [@Error when accessing \_index in script\_score](https://discuss.elastic.co/t/error-when-accessing--index-in-script-score/63109/2):
>
> It seems \_index is not supported in painless language. Change "lang" to "groovy", and the query will work. Also note that you need to turn on groovy inline script in ES 5.

---

_[View the full topic](https://discuss.elastic.co/t/accessing--index-variable-inside-painless-script/82362)._
