# How do I access the \_id field in Painless?

**URL:** <https://discuss.elastic.co/t/how-do-i-access-the--id-field-in-painless/66338>\
**Category:** Elasticsearch\
**Created:** [November 17, 2016, 7:27am UTC](https://discuss.elastic.co/t/how-do-i-access-the--id-field-in-painless/66338 "2016-11-17T07:27:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tal\_Weiss](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tal_weiss/32/13021_2.png) [@Tal\_Weiss](https://discuss.elastic.co/u/Tal_Weiss)\
**Post date:** [November 17, 2016, 7:27am UTC](https://discuss.elastic.co/t/how-do-i-access-the--id-field-in-painless/66338/1 "2016-11-17T07:27:43Z")

</div>

Every time I try something like this:

doc['\_id'] + "/" + doc['site\_code'].value  
doc['\_index'] + "/" + doc['site\_code'].value  
ctx.\_index + "/" + doc['site\_code'].value

All shards crash???

Not very friendly. I'm trying a scripted filed via Kibana with latest hosting plan.

---

<div class="post-metadata">

**Author:** ![igor\_k](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_k/32/1157_2.png) [@igor\_k](https://discuss.elastic.co/u/igor_k)\
**Post date:** [November 17, 2016, 10:32am UTC](https://discuss.elastic.co/t/how-do-i-access-the--id-field-in-painless/66338/2 "2016-11-17T10:32:49Z")

</div>

Hi @Tal_Weiss, I moved your post to `elasticsearch` category as I think that it can get a better answer here.

Thanks,  
Igor

---

<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:** [November 20, 2016, 10:33am UTC](https://discuss.elastic.co/t/how-do-i-access-the--id-field-in-painless/66338/3 "2016-11-20T10:33:15Z")

</div>

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