# Elasticsearch Set Processor Variable not define errror

**URL:** <https://discuss.elastic.co/t/elasticsearch-set-processor-variable-not-define-errror/358769>\
**Category:** Elasticsearch\
**Tags:** painless, ingest-pipeline\
**Created:** [May 6, 2024, 4:36am UTC](https://discuss.elastic.co/t/elasticsearch-set-processor-variable-not-define-errror/358769 "2024-05-06T04:36:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tusharnemade](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tusharnemade](https://discuss.elastic.co/u/tusharnemade)\
**Post date:** [May 6, 2024, 4:36am UTC](https://discuss.elastic.co/t/elasticsearch-set-processor-variable-not-define-errror/358769/1 "2024-05-06T04:36:17Z")

</div>

Hello Everyone:

I am using Elasticsearch 7.8 version.

I have a mutliple conditions to be checked using set processor ...

I am using below code

```auto
curl -X POST "localhost:9200/_ingest/pipeline/_simulate?pretty" -H 'Content-Type: application/json' -d'
{
  "docs": [
    { "_source" : { "outer": {"inner": "X"} } },
    { "_source" : { "outer": {"inner": "Y"} } },
    { "_source" : { "outer": {"inner": "Z"} } },
    { "_source" : { "outer": {"inner": "T"} } }
    ],
  "pipeline": {
    "processors": [
      {
        "set": {
          "if": "ctx.containsKey('outer') && ctx['outer'].containsKey('inner') && ctx.outer.inner == 'Y'",
          "field": "added_field",
          "value": "added_value"
        }
      }
    ]
  }
}' -u $ES_USER:$ES_PASS

```

This code is not working and giving me ERROR :

```auto
{
  "docs" : [
    {
      "error" : {
        "root_cause" : [
          {
            "type" : "script_exception",
            "reason" : "compile error",
            "script_stack" : [
              "ctx.containsKey(outer) && ctx[outer].cont ...",
              " ^---- HERE"
            ],
            "script" : "ctx.containsKey(outer) && ctx[outer].containsKey(inner) && ctx.outer.inner == Y",
            "lang" : "painless",
            "position" : {
              "offset" : 16,
              "start" : 0,
              "end" : 41
            }
          }
        ],
        "type" : "script_exception",
        "reason" : "compile error",
        "script_stack" : [
          "ctx.containsKey(outer) && ctx[outer].cont ...",
          " ^---- HERE"
        ],
        "script" : "ctx.containsKey(outer) && ctx[outer].containsKey(inner) && ctx.outer.inner == Y",
        "lang" : "painless",
        "position" : {
          "offset" : 16,
          "start" : 0,
          "end" : 41
        },
        "caused_by" : {
          "type" : "illegal_argument_exception",
          "reason" : "Variable [outer] is not defined."
        }
      }
    },

```

Could someone please help me what I am missing in here ...

Reference : [Use conditional if in a Set processor - Elastic Stack / Elasticsearch - Discuss the Elastic Stack]([Use conditional if in a Set processor](https://discuss.elastic.co/t/use-conditional-if-in-a-set-processor/184971)

---

<div class="post-metadata">

**Author:** ![tusharnemade](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tusharnemade](https://discuss.elastic.co/u/tusharnemade)\
**Post date:** [May 7, 2024, 9:21am UTC](https://discuss.elastic.co/t/elasticsearch-set-processor-variable-not-define-errror/358769/2 "2024-05-07T09:21:38Z")

</div>

Hello Team:

Could someone please help me ...
