Enrichment policy based on multiple fields / complex query?

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:

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

Incoming data may look like:

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

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

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

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

{
  "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!

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