# Painless unable to access any field

**URL:** https://discuss.elastic.co/t/painless-unable-to-access-any-field/152633
**Category:** Elasticsearch
**Created:** [October 16, 2018, 10:50am UTC](https://discuss.elastic.co/t/painless-unable-to-access-any-field/152633 "2018-10-16T10:50:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Alex\_Zeleznikov](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@Alex\_Zeleznikov](https://discuss.elastic.co/u/Alex_Zeleznikov)
#### Post date: [October 16, 2018, 10:50am UTC](https://discuss.elastic.co/t/painless-unable-to-access-any-field/152633/1 "2018-10-16T10:50:37Z")

</div>

I'm trying to use painless to extract a substring from a field, however it seems painless is unable to access ANY fields.

Tried all of the below and they all fail (and I've checked that the fields exists, it's the default metricbeat fields):

```auto
doc.containsKey('docker.container.image.keyword') ? doc['docker.container.image.keyword'].value : 'none'

```

```auto
def image = doc['docker.container.image.keyword'].value;
if (image != null) {
   int lastSlashIndex = image.lastIndexOf(':');
   if (lastSlashIndex > 0) {
   return image.substring(lastSlashIndex+1);
   }
}
return 'none';

```

Tried with and without `keyword`, tried filtering the search to documents that contains the specified fields, even a simple `doc['beat.name.keyword'].value` return `"No field found for [beat.name.keyword] in mapping with types []"`

---

<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 16, 2018, 4:38pm UTC](https://discuss.elastic.co/t/painless-unable-to-access-any-field/152633/2 "2018-10-16T16:38:45Z")

</div>

The error message you past shows a field `beat.name.keyword`, but your code shows `docker.container.image.keyword`. This error means the field does not exist in the mappings. So I would start by checking that field exists in your mappings (and note that it must exist in the mappings for all indexes you are searching).

---

<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 13, 2018, 4:38pm UTC](https://discuss.elastic.co/t/painless-unable-to-access-any-field/152633/3 "2018-11-13T16:38:47Z")

</div>

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