# Using Ingest node Enrich your data with "multiple" match fields

**URL:** <https://discuss.elastic.co/t/using-ingest-node-enrich-your-data-with-multiple-match-fields/211300>\
**Category:** Elasticsearch\
**Created:** [December 10, 2019, 12:42pm UTC](https://discuss.elastic.co/t/using-ingest-node-enrich-your-data-with-multiple-match-fields/211300 "2019-12-10T12:42:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cho](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cho/32/46457_2.png) [@cho](https://discuss.elastic.co/u/cho)\
**Post date:** [December 10, 2019, 12:42pm UTC](https://discuss.elastic.co/t/using-ingest-node-enrich-your-data-with-multiple-match-fields/211300/1 "2019-12-10T12:42:24Z")

</div>

Hey there.

I've been experimenting with the newly added data enrichment funtions in ES 7.5 and came up with the following problem.

Let's pretend we have those indices:

_article\_to\_group_

```
{
  "article_key": 123456,
  "article_group": "foobars"
}

```

_article\_views\_from\_other\_data\_source_

```
{
  "date": "2019-12-10",
  "article_group": "foobars",
  "other_views": 1440
}

```

**Building the enrichtment process**

I came up with the following so far:

```
PUT /_enrich/policy/group_policy
{
    "match": {
        "indices": [
            "article_to_group"
        ],
        "match_field": "article_key",
        "enrich_fields": ["article_group"]
    }
}
POST /_enrich/policy/group_policy/_execute

PUT /_enrich/policy/other_views_policy
{
    "match": {
        "indices": [
            "article_views_from_other_data_source"
        ],
        "match_field": "article_group",
        "enrich_fields": ["other_views"]
    }
}
POST /_enrich/policy/other_views_policy/_execute

// Create pipeline
PUT /_ingest/pipeline/views_lookup
{
  "description" : "Enriching...",
  "processors" : [
    {
        "enrich" : {
          "policy_name": "group_policy",
          "field" : "article_key",
          "target_field": "info",
          "max_matches": "1"
        }
    },
    {
      "enrich" : {
        "policy_name": "other_views_policy",
        "field" : "info.article_group",
        "target_field": "other_views",
        "max_matches": "1"
      }
    }
  ]
}

```

**Execute our pipeline**

```
POST /my_test_index/_doc/1?pipeline=views_lookup
{
  "article_key": 123456,
  "views": 1337
}

```

**Result of ` GET /my_test_index/_doc/1` is**

```
{
    "other_views" : {
      "other_views" : 1440,
      "article_group" : "foobars"
    },
    "article_key" : 123456,
    "views" : 1337,
    "info" : {
      "article_key" : 123456,
      "article_group" : "foobars"
    }
}

```

Unfortunately this won't work as soon as there are mutiple logs in the `article_views_from_other_data_source` with the same `article_group`, but different dates.

Is there a way to define date as a "second" `match_field` in the pipeline definition with the query field?

---

<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:** [January 7, 2020, 12:42pm UTC](https://discuss.elastic.co/t/using-ingest-node-enrich-your-data-with-multiple-match-fields/211300/2 "2020-01-07T12:42:25Z")

</div>

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