# Using lookup fields in Runtime mappings with nested fields

**URL:** <https://discuss.elastic.co/t/using-lookup-fields-in-runtime-mappings-with-nested-fields/357612>\
**Category:** Elasticsearch\
**Tags:** painless, runtime-fields\
**Created:** [April 17, 2024, 12:40pm UTC](https://discuss.elastic.co/t/using-lookup-fields-in-runtime-mappings-with-nested-fields/357612 "2024-04-17T12:40:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thijsvdp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thijsvdp/32/146696_2.png) [@Thijsvdp](https://discuss.elastic.co/u/Thijsvdp)\
**Post date:** [April 17, 2024, 12:40pm UTC](https://discuss.elastic.co/t/using-lookup-fields-in-runtime-mappings-with-nested-fields/357612/1 "2024-04-17T12:40:10Z")

</div>

I saw in the documentation that there is support for lookup type in runtime\_mappings . I have tried it, and it seems to work. However, I have the following issue:

- I have some nested field called members , and I would like to enrich the field members.code with some fields from the index code\_definitions .
- I cannot make it work. I feel the problem is the nested field here. Is this correct, or am I missing something else?

Here is a (simplified) version of my query:

```auto
POST families/_search
{
  "query": {
    "match_all": {}
  },
  "runtime_mappings": {
    "members.code_name": {
      "type": "lookup",
      "target_index": "code_definitions",
      "input_field": "members.code.keyword",
      "target_field": "code.keyword",
      "fetch_fields": ["code_name"]
    }
  },
  "fields": [
    "members.code_name"
  ],
  "_source": false
}

```

Am I missing something, or is there some other way to implement such lookups? Maybe using painless?
