# How to manage array with dynamic\_templates

**URL:** <https://discuss.elastic.co/t/how-to-manage-array-with-dynamic-templates/334109>\
**Category:** Elasticsearch\
**Created:** [May 23, 2023, 11:26am UTC](https://discuss.elastic.co/t/how-to-manage-array-with-dynamic-templates/334109 "2023-05-23T11:26:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julien\_Revol](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julien_revol/32/106083_2.png) [@Julien\_Revol](https://discuss.elastic.co/u/Julien_Revol)\
**Post date:** [May 23, 2023, 11:26am UTC](https://discuss.elastic.co/t/how-to-manage-array-with-dynamic-templates/334109/1 "2023-05-23T11:26:49Z")

</div>

hello,  
i want to use dynamic mapping an manage array of object by making them defined as arrays.  
it works when i define the field directly:

```auto
"tx.chargingSessionEvents": {
          "type": "nested"
        },

```

but i would like elasticsearch to detect arrays and use nested automatically.  
I've tried something like that :

```auto
"dynamic_templates": [
        {
          "Arrays": {
            "match_mapping_type": "array",
            "mapping": {
              "type": "nested"
            }
          }
        }
]

```

i thought i would work considering [this part of the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html#match-mapping-type)  
And using the java client i got this error:  
No field type matched on [array], possible values are [object, string, long, double, boolean, date, binary]

Am i missing something or is there a kind of limitation i didn't thought about ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 23, 2023, 12:39pm UTC](https://discuss.elastic.co/t/how-to-manage-array-with-dynamic-templates/334109/2 "2023-05-23T12:39:30Z")

</div>

Bonjour Julien 😉

No I don't think it's possible actually.

---

<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:** [May 23, 2023, 1:00pm UTC](https://discuss.elastic.co/t/how-to-manage-array-with-dynamic-templates/334109/3 "2023-05-23T13:00:42Z")

</div>

> [@Julien\_Revol](#):
>
> Am i missing something or is there a kind of limitation i didn't thought about ?

There is no dedicated [array datatype](https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html) in Elasticsearch, that's why you got that error.

You will need to use explict mapping in this case.

---

<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:** [June 20, 2023, 1:00pm UTC](https://discuss.elastic.co/t/how-to-manage-array-with-dynamic-templates/334109/4 "2023-06-20T13:00:50Z")

</div>

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