Using lookup fields in Runtime mappings with nested fields

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:

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?