# Field mapping \[field with constant name\]. --\> \[field with a changing/dynamic name\] --\> \[fields with constant names\]

**URL:** <https://discuss.elastic.co/t/field-mapping-field-with-constant-name-field-with-a-changing-dynamic-name-fields-with-constant-names/339886>\
**Category:** Elasticsearch\
**Created:** [August 2, 2023, 4:49am UTC](https://discuss.elastic.co/t/field-mapping-field-with-constant-name-field-with-a-changing-dynamic-name-fields-with-constant-names/339886 "2023-08-02T04:49:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stcdarrell](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@stcdarrell](https://discuss.elastic.co/u/stcdarrell)\
**Post date:** [August 2, 2023, 4:49am UTC](https://discuss.elastic.co/t/field-mapping-field-with-constant-name-field-with-a-changing-dynamic-name-fields-with-constant-names/339886/1 "2023-08-02T04:49:21Z")

</div>

hi.. i've run into a problem with elasticsearch mapping.. i'm sure there is a way to deal with it.. but i cant figure it out.. or even the terminology to use to search for a solution.

i'm trying to import a json from [shodan.io](http://shodan.io) i've got everything mapped other than a field called "vulns"

within vulns are seperate fields named by the vulnerability-year-id .. then subfields with standard names in there.

for example:

vulns.cve-2018-0732.references  
vulns.cve-2018-0732.summary  
vulns.cve-2018-0732.verified  
vulns.cve-2018-1737.references  
vulns.cve-2018-1737.summary  
vulns.cve-2018-1737.verified

i need the cve-\* names .. after that it can just be flatteend to text.. but how do i map that with the name after "cve-" constantly changing? is where a way to do a mapping to a name with a wildcard:  
cve-\* --\> flattened?

any help would be appreciated

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [August 2, 2023, 5:04am UTC](https://discuss.elastic.co/t/field-mapping-field-with-constant-name-field-with-a-changing-dynamic-name-fields-with-constant-names/339886/2 "2023-08-02T05:04:09Z")

</div>

> [@stcdarrell](#):
>
> is where a way to do a mapping to a name with a wildcard:  
> cve-\* --\> flattened?

Take a look at the [dynamic templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html#dynamic-templates) documentation.

I think it would be something like this, but I didn't tested it.

```auto
"dynamic_templates" : [
    {
        "vulns_cve" : {
            "path_match" : "vulns.cve-*",
            "mapping" : {
                "type" : "flattened"
            }
        }
    }
]

```

This would map every field starting with `cve-*` nested under `vulns` as flattened, for example, `vulns.cve-2018-0732.references` would be mapped as `flattened`.

---

<div class="post-metadata">

**Author:** ![stcdarrell](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@stcdarrell](https://discuss.elastic.co/u/stcdarrell)\
**Post date:** [August 2, 2023, 5:12am UTC](https://discuss.elastic.co/t/field-mapping-field-with-constant-name-field-with-a-changing-dynamic-name-fields-with-constant-names/339886/3 "2023-08-02T05:12:34Z")

</div>

thank you, i dont know why i was making that so hard. you saved me a ton of time.

---

<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 30, 2023, 5:12am UTC](https://discuss.elastic.co/t/field-mapping-field-with-constant-name-field-with-a-changing-dynamic-name-fields-with-constant-names/339886/4 "2023-08-30T05:12:41Z")

</div>

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