# Question About Null Conditional

**URL:** <https://discuss.elastic.co/t/question-about-null-conditional/297187>\
**Category:** Beats\
**Tags:** beats-module, filebeat\
**Created:** [February 14, 2022, 7:41pm UTC](https://discuss.elastic.co/t/question-about-null-conditional/297187 "2022-02-14T19:41:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![msr1716](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@msr1716](https://discuss.elastic.co/u/msr1716)\
**Post date:** [February 14, 2022, 7:41pm UTC](https://discuss.elastic.co/t/question-about-null-conditional/297187/1 "2022-02-14T19:41:02Z")

</div>

I am using an Elasticsearch ingest pipeline in a Filebeat module, and I see the statement of: if: 'ctx.json?.userIdentity?.userName == null'

When json.userIdentity.userName is equal to null, what would the key/value pair look like when the if statement above would be true? {"json.userIdentity.userName":"null"}, {"json.userIdentity.userName":null}, or something else

In addition, is it fair to say that if the field doesnt exist, then the key is also equal to null?

---

<div class="post-metadata">

**Author:** ![Andrea\_Spacca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrea_spacca/32/76976_2.png) [@Andrea\_Spacca](https://discuss.elastic.co/u/Andrea_Spacca)\
**Post date:** [February 16, 2022, 1:31pm UTC](https://discuss.elastic.co/t/question-about-null-conditional/297187/2 "2022-02-16T13:31:23Z")

</div>

Hello @msr1716

welcome to the community!

What version of Filebeat and module are you referring to?  
I cannot find a `ctx.json?.userIdentity?.userName == null`, but rather a `ctx.json?.userIdentity?.userName != null` in the aws cloudtrail ingest pipeline.

```auto
  - append:
      field: related.user
      value: '{{json.userIdentity.userName}}'
      allow_duplicates: false
      if: 'ctx.json?.userIdentity?.userName != null'

```

this processor will add the field `related.user` if `json.userIdentity.userName` is set and not null  
if `json.userIdentity.userName` is not set or has a null value the processor will be not applied and the field `related.user` not set

This is an ingest pipeline on the Elasticsearch side

Regarding the last question, yes, you are right, if a field does not exist the value is `null`

---

<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:** [March 16, 2022, 3:32pm UTC](https://discuss.elastic.co/t/question-about-null-conditional/297187/3 "2022-03-16T15:32:12Z")

</div>

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