# Access field name with blanks via painless

**URL:** <https://discuss.elastic.co/t/access-field-name-with-blanks-via-painless/194062>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [August 6, 2019, 4:46pm UTC](https://discuss.elastic.co/t/access-field-name-with-blanks-via-painless/194062 "2019-08-06T16:46:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brille1980](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@brille1980](https://discuss.elastic.co/u/brille1980)\
**Post date:** [August 6, 2019, 4:46pm UTC](https://discuss.elastic.co/t/access-field-name-with-blanks-via-painless/194062/1 "2019-08-06T16:46:14Z")

</div>

Hi there,

how do I access a field name that includes blanks (e.g. "Event ID" : 23) via script?

`ctx.Event\ ID = 42` doesn't work ("Error parsing ingest pipeline: JSON Parse error: Invalid escape character")  
neither does ctx.'System Name'.

Any idea?

Thanks and cheers,  
Markus

---

<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:** [August 6, 2019, 7:45pm UTC](https://discuss.elastic.co/t/access-field-name-with-blanks-via-painless/194062/2 "2019-08-06T19:45:49Z")

</div>

`ctx` is a Map. The fact it works with bare keys as if they were members of an object is the result of easing migration from groovy scripts when painless was first added.

You can access any key within a Map, regardless of spaces or special characters, using bracket syntax:

```auto
ctx['Event ID'] = 42;

```

---

<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:** [September 3, 2019, 7:45pm UTC](https://discuss.elastic.co/t/access-field-name-with-blanks-via-painless/194062/3 "2019-09-03T19:45:50Z")

</div>

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