# Can't use multiple enrich policies in the same ingest pipeline

**URL:** https://discuss.elastic.co/t/cant-use-multiple-enrich-policies-in-the-same-ingest-pipeline/317219
**Category:** Elasticsearch
**Tags:** ingest-pipeline
**Created:** [October 21, 2022, 4:29pm UTC](https://discuss.elastic.co/t/cant-use-multiple-enrich-policies-in-the-same-ingest-pipeline/317219 "2022-10-21T16:29:12Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)
#### Post date: [October 21, 2022, 4:29pm UTC](https://discuss.elastic.co/t/cant-use-multiple-enrich-policies-in-the-same-ingest-pipeline/317219/1 "2022-10-21T16:29:12Z")

</div>

Hi Im trying to add enrich policies in the same ingest pipeline, but when I try to test it with this simulation I get an error.

```auto
POST /_ingest/pipeline/my-pipe/_simulate?verbose=true
{
  "docs": [
    {
      "_index": "index",
      "_id": "id",
      "_source": {
        "ServiceCode": "LHO0000005"
      }
    }
  ]
}

```

This is the error I get:

```auto
{
  "docs": [
    {
      "processor_results": [
        {
          "processor_type": "enrich",
          "status": "success",
          "doc": {
            "_id": "id",
            "_index": "index",
            "_version": "-3",
            "_source": {
              "new": {
                "codigo_servicio": "LHO0000005",
                "servicio": "Cancel LH to Paytech"
              },
              "ServiceCode": "LHO0000005"
            },
            "_ingest": {
              "pipeline": "my-pipe",
              "timestamp": "2022-10-21T16:16:47.294338399Z"
            }
          }
        },
        {
          "processor_type": "enrich",
          "status": "error",
          "error": {
            "root_cause": [
              {
                "type": "illegal_argument_exception",
                "reason": "field [Syscode] not present as part of path [Syscode]"
              }
            ],
            "type": "illegal_argument_exception",
            "reason": "field [Syscode] not present as part of path [Syscode]"
          }
        }
      ]
    }
  ]
}

```

This is my ingest pipeline:

```auto
{
  "my-pipe": {
    "processors": [
      {
        "enrich": {
          "field": "ServiceCode",
          "policy_name": "agrega_servicios",
          "target_field": "new"
        }
      },
      {
        "enrich": {
          "field": "Syscode",
          "policy_name": "agrega_sistemas",
          "target_field": "new"
        }
      },
      {
        "enrich": {
          "field": "ProcessCode",
          "policy_name": "agrega_productos",
          "target_field": "new"
        }
      }
    ]
  }
}

```

So, when its get to the second enrich policy produce an error. it all about the order of the procesors. they all work alone, but not when I use them in the same pipeline

Any advice?

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [October 21, 2022, 5:03pm UTC](https://discuss.elastic.co/t/cant-use-multiple-enrich-policies-in-the-same-ingest-pipeline/317219/2 "2022-10-21T17:03:30Z")

</div>

Please share your enrich policies.

---

<div class="post-metadata">

### Author: ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)
#### Post date: [October 21, 2022, 5:07pm UTC](https://discuss.elastic.co/t/cant-use-multiple-enrich-policies-in-the-same-ingest-pipeline/317219/3 "2022-10-21T17:07:29Z")

</div>

```auto

PUT /_enrich/policy/agrega_productos
{
  "match": {
    "indices": "diccionario_productos",  
    "match_field": "codigo_proceso",   
    "enrich_fields": ["producto"]       
  }
}

PUT /_enrich/policy/agrega_servicios
{
  "match": {
    "indices": "diccionario_servicios",   
    "match_field": "codigo_servicio",     
    "enrich_fields": ["servicio"]      
  }
}

PUT /_enrich/policy/agrega_sistemas
{
  "match": {
    "indices": "diccionario_sistemas",   
    "match_field": "codigo_sistema",  
    "enrich_fields": ["sistema"]     
}

```

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [October 21, 2022, 5:23pm UTC](https://discuss.elastic.co/t/cant-use-multiple-enrich-policies-in-the-same-ingest-pipeline/317219/4 "2022-10-21T17:23:13Z")

</div>

Ohh Edit... Sorry

```auto
POST /_ingest/pipeline/my-pipe/_simulate?verbose=true
{
  "docs": [
    {
      "_index": "index",
      "_id": "id",
      "_source": {
        "ServiceCode": "LHO0000005"
      }
    }
  ]
}

```

If this ^^^ is the document you are testing of course it will fail.

There is no field `Syscode`  
`"reason": "field [Syscode] not present as part of path [Syscode]"`

If you want to to drop through you need to add the

`ignore_failure: true` to each processor

Your pipeline as you defined would only work if you had all 3 fields

```auto
ServiceCode
Syscode
ProcessCode

```

---

<div class="post-metadata">

### Author: ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)
#### Post date: [October 21, 2022, 5:55pm UTC](https://discuss.elastic.co/t/cant-use-multiple-enrich-policies-in-the-same-ingest-pipeline/317219/5 "2022-10-21T17:55:43Z")

</div>

Thanks @stephenb! I also realize that if I add a condition can make it work too `ctx.containsKey('<source field')`

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [October 21, 2022, 6:06pm UTC](https://discuss.elastic.co/t/cant-use-multiple-enrich-policies-in-the-same-ingest-pipeline/317219/6 "2022-10-21T18:06:24Z")

</div>

Oh yes conditions... that is good way too!

---

<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: [November 18, 2022, 6:06pm UTC](https://discuss.elastic.co/t/cant-use-multiple-enrich-policies-in-the-same-ingest-pipeline/317219/7 "2022-11-18T18:06:44Z")

</div>

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