# Give wildcard for fieldname in emit() when creating Runtime field throws error

**URL:** <https://discuss.elastic.co/t/give-wildcard-for-fieldname-in-emit-when-creating-runtime-field-throws-error/339394>\
**Category:** Elasticsearch\
**Tags:** runtime-fields\
**Created:** [July 27, 2023, 7:35am UTC](https://discuss.elastic.co/t/give-wildcard-for-fieldname-in-emit-when-creating-runtime-field-throws-error/339394 "2023-07-27T07:35:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sheereen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sheereen/32/122005_2.png) [@Sheereen](https://discuss.elastic.co/u/Sheereen)\
**Post date:** [July 27, 2023, 7:35am UTC](https://discuss.elastic.co/t/give-wildcard-for-fieldname-in-emit-when-creating-runtime-field-throws-error/339394/1 "2023-07-27T07:35:08Z")

</div>

Hi,

I have a field, say **macAddress in all my documents, but with different names**. Like in some documents, it is **host.macAddress** , while in some it is **machine.mac** and so on.

I want to **create a runtime field called macAddress** , which will map any field of the form **mac** to it.

Meaning, now all the docs will have a **common macAddress field (same field name).**. I can use the same for aggregations.

I tried the below:

```auto
PUT _component_template/xx-runtime-mappings
{
  "template": {
    "mappings": {
      "runtime": {
        "macAddress": {
          "type": "long",
          "script": {
            "source": "emit(doc['*mac*'].value)"
          }
        }
      }
    }
  },
  "_meta": {
    "description": "Mapping for macAddress fields"
  }
}

```

  

Doesn't through an error when I execute this, but when querying giving **fields: [\*]**, throws error:

```auto
"caused_by": {
            "type": "illegal_argument_exception",
            "reason": "No field found for [*mac*] in mapping"
          }

```

  
Thanks

---

<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 24, 2023, 7:35am UTC](https://discuss.elastic.co/t/give-wildcard-for-fieldname-in-emit-when-creating-runtime-field-throws-error/339394/2 "2023-08-24T07:35:43Z")

</div>

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