# Ingest Pipeline - Check if a field exists

**URL:** <https://discuss.elastic.co/t/ingest-pipeline-check-if-a-field-exists/238040>\
**Category:** Elasticsearch\
**Created:** [June 22, 2020, 8:34am UTC](https://discuss.elastic.co/t/ingest-pipeline-check-if-a-field-exists/238040 "2020-06-22T08:34:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sean\_wills](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@sean\_wills](https://discuss.elastic.co/u/sean_wills)\
**Post date:** [June 22, 2020, 8:34am UTC](https://discuss.elastic.co/t/ingest-pipeline-check-if-a-field-exists/238040/1 "2020-06-22T08:34:45Z")

</div>

Hello,

I'm trying to do something that seems like it should be relatively simple, but I haven't been able to track down the correct syntax the documentation. I have a basic ingest pipeline which I want to use to reference other pipelines depending on whether a specific field exists in a given document. Basically something like this:

```auto
    { 
    "processors" : [
      {
        "pipeline" : {
          "name" : "generic_pipeline",
          "if": "[field1 does not exist]"
        }
      },
      {
        "pipeline": {
          "name": "specific_pipeline",
          "if": "[field1 does exist]"
        }
      }
    ]
    }

```

This wouldn't be a problem if I was just checking for the field's values, but I'm having trouble working out how to check if the field exists in the first place. Any assistance would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Vinayak\_Sapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinayak_sapre/32/45939_2.png) [@Vinayak\_Sapre](https://discuss.elastic.co/u/Vinayak_Sapre)\
**Post date:** [July 17, 2020, 9:07am UTC](https://discuss.elastic.co/t/ingest-pipeline-check-if-a-field-exists/238040/2 "2020-07-17T09:07:48Z")

</div>

@sean_wills  
try `"if" : "!(ctx.containsKey('field1'))"` and `"if" : "ctx.containsKey('field1')"` respectively

---

<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:** [August 14, 2020, 9:20am UTC](https://discuss.elastic.co/t/ingest-pipeline-check-if-a-field-exists/238040/3 "2020-08-14T09:20:59Z")

</div>

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