# Enrichment policy based on multiple fields / complex query?

**URL:** <https://discuss.elastic.co/t/enrichment-policy-based-on-multiple-fields-complex-query/308826>\
**Category:** Elasticsearch\
**Created:** [July 4, 2022, 4:09pm UTC](https://discuss.elastic.co/t/enrichment-policy-based-on-multiple-fields-complex-query/308826 "2022-07-04T16:09:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![akb](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@akb](https://discuss.elastic.co/u/akb)\
**Post date:** [July 4, 2022, 4:09pm UTC](https://discuss.elastic.co/t/enrichment-policy-based-on-multiple-fields-complex-query/308826/1 "2022-07-04T16:09:58Z")

</div>

I am investigating a way to _ **normalize / prettify geo data during ingestion** _.  
I realize there is a way to normalize by lat / lon, however we don't always have these properties availble.

**Master geo data:**

```auto
{
  "country": "de",
  "region": "Bayern",
  "region_alternate": ["Bavaria"],
  "city": "München",
  "city_alternate": ["Munich", "Muenchen"]
}

```

**Incoming data may look like:**

```auto
{
  "country": "de",
  "region": "Bavaria",
  "city": "Munich"
}

```

**What I need to achieve is to store this geo version of incoming data in index:**

```auto
{
  "country": "de",
  "region": "Bayern",
  "city": "München"
}

```

**To find this in master geo data , I can use the following query:**

```auto
{
  "explain": false,
  "query": {
    "bool": {
      "filter": [
        {
          "terms": {
            "country_code": [
              "de"
            ]
          }
        }
      ],
      "must": [
        {
          "multi_match": {
            "fields": [
              "region",
              "region_alternate"
            ],
            "query": "Bavaria"
          }
        },
        {
          "multi_match": {
            "fields": [
              "city",
              "city_alternate"
            ],
            "query": "Munich"
          }
        }
      ]
    }
  }
}

```

Is it possible to create an _ **enrichment policy that is based on a more complex lookup rather than just a term query on a single field** _?

Any other ideas on how this geo normalization / prettifying could be achieved during data ingestion?

Thanks for any help or pointers to look into!

---

<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 1, 2022, 4:10pm UTC](https://discuss.elastic.co/t/enrichment-policy-based-on-multiple-fields-complex-query/308826/2 "2022-08-01T16:10:47Z")

</div>

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