# Foreach Ingest processor + condition

**URL:** <https://discuss.elastic.co/t/foreach-ingest-processor-condition/309435>\
**Category:** Elasticsearch\
**Tags:** ingest-pipeline\
**Created:** [July 12, 2022, 3:15pm UTC](https://discuss.elastic.co/t/foreach-ingest-processor-condition/309435 "2022-07-12T15:15:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vladislav](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@vladislav](https://discuss.elastic.co/u/vladislav)\
**Post date:** [July 12, 2022, 3:15pm UTC](https://discuss.elastic.co/t/foreach-ingest-processor-condition/309435/1 "2022-07-12T15:15:21Z")

</div>

Hello!  
Please advice. I have documents with fields looks like this

```auto
{
"something": "some value",
...
 "outdated_products": [
      {
        "product": "Google Chrome earlier than 101.0.1034.124"
      }
    ],
  "software": [
         "Google Chrome",
         "Mozilla Firefox"
    ],
}

```

I need to add field 'used: True' if one item of array "software" contained in "outdated\_products"  
That's what i did:  
I added foreach ingest processor with following settings

```auto
    {
      "foreach": {
        "field": "software",
        "processor": {
          "set": {
            "field": "used",
            "value": "true"
          }
        },
        "if": "ctx.outdated_products[0].product.contains('_ingest._value')",
        "ignore_failure": true
      }
    },

```

but nothing happens. If I add value of software directly instead of '\_ingest.\_value' everything works fine. Where I'm wrong?

---

<div class="post-metadata">

**Author:** ![vincenbr](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@vincenbr](https://discuss.elastic.co/u/vincenbr)\
**Post date:** [July 13, 2022, 9:55am UTC](https://discuss.elastic.co/t/foreach-ingest-processor-condition/309435/2 "2022-07-13T09:55:04Z")

</div>

Hello,  
you seem to be hitting this bug [Can not access \_ingest metadata from painless scripting · Issue #60470 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/60470)  
-\> `_ingest._value` is not added in the painless context, thus unavailable in the `if`  
suggestions:

- set an (inconditional) temporary field in the `foreach` as suggested in the issue, and use it in a later `set` processor
- make a script instead of the `foreach` (if you're comfortable with java/painless)

---

<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 10, 2022, 9:55am UTC](https://discuss.elastic.co/t/foreach-ingest-processor-condition/309435/3 "2022-08-10T09:55:42Z")

</div>

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