# Determine if field containing special characters in name is not null in Elasticsearch ingest pipeline

**URL:** <https://discuss.elastic.co/t/determine-if-field-containing-special-characters-in-name-is-not-null-in-elasticsearch-ingest-pipeline/322406>\
**Category:** Elasticsearch\
**Tags:** ingest-pipeline\
**Created:** [January 3, 2023, 10:04pm UTC](https://discuss.elastic.co/t/determine-if-field-containing-special-characters-in-name-is-not-null-in-elasticsearch-ingest-pipeline/322406 "2023-01-03T22:04:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DougR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dougr/32/48095_2.png) [@DougR](https://discuss.elastic.co/u/DougR)\
**Post date:** [January 3, 2023, 10:04pm UTC](https://discuss.elastic.co/t/determine-if-field-containing-special-characters-in-name-is-not-null-in-elasticsearch-ingest-pipeline/322406/1 "2023-01-03T22:04:57Z")

</div>

I'm monitoring a set of pods using elastic-agent which have labels which resolve to the following format when ingested:

```auto
kubernetes.labels.foo_bar/baz: value

```

I need to do something in Elasticsearch ingest pipeline if this field is present. For labels without special characters (e.g., `kubernetes.labels.env`), the following statement works:

```json
{
    ...
    if: "ctx?.kubernetes?.labels?.env != null"
}

```

However, this does not work for label values which contain special characters, such as `/-`. How can I make this work?

---

<div class="post-metadata">

**Author:** ![DougR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dougr/32/48095_2.png) [@DougR](https://discuss.elastic.co/u/DougR)\
**Post date:** [January 25, 2023, 2:10pm UTC](https://discuss.elastic.co/t/determine-if-field-containing-special-characters-in-name-is-not-null-in-elasticsearch-ingest-pipeline/322406/2 "2023-01-25T14:10:47Z")

</div>

I was able to figure this out this morning. The `if` statement is:

```auto
ctx?.kubernetes?.labels != null && ctx.kubernetes.labels.containsKey('foo_bar/baz')

```

---

<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:** [February 22, 2023, 2:11pm UTC](https://discuss.elastic.co/t/determine-if-field-containing-special-characters-in-name-is-not-null-in-elasticsearch-ingest-pipeline/322406/3 "2023-02-22T14:11:05Z")

</div>

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