# Mapping Array of Arrays that have mapped fields?

**URL:** <https://discuss.elastic.co/t/mapping-array-of-arrays-that-have-mapped-fields/207417>\
**Category:** Elasticsearch\
**Created:** [November 11, 2019, 10:11pm UTC](https://discuss.elastic.co/t/mapping-array-of-arrays-that-have-mapped-fields/207417 "2019-11-11T22:11:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikeRead](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@mikeRead](https://discuss.elastic.co/u/mikeRead)\
**Post date:** [November 11, 2019, 10:11pm UTC](https://discuss.elastic.co/t/mapping-array-of-arrays-that-have-mapped-fields/207417/1 "2019-11-11T22:11:35Z")

</div>

I want to map a field to store data like so  
`field1:[[ {val:1}, {val:2}], [{val:3}], [{val:4}] ]`

For the life of me I can't find how to map all the way down to "val:number"  
Thank you for any help even its just saying it is or isn't possible.

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [November 13, 2019, 10:09am UTC](https://discuss.elastic.co/t/mapping-array-of-arrays-that-have-mapped-fields/207417/2 "2019-11-13T10:09:21Z")

</div>

Elasticsearch does not have a specialistic array type: any field accepts 0 or more values. The mapping of your document could simply be:

```auto
PUT my_index
{
  "mappings": {
    "properties": {
      "field1": {
        "properties": {
          "val": {
            "type": "integer"
          }
        }
      }
    }
  }
}

```

It's good to point out here that Elasticsearch will flatten your document. In your example, indexing the following document would have the same result:

```auto
{
  "field1": {
    "val": [
      1,
      2,
      3,
      4
    ]
  }
}

```

If you want to index arrays of objects, and really treat them as separate objects, you may want to consider using nested types instead. [Check the docs for an explanation](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html). Your mapping would become:

```auto
PUT my_index
{
  "mappings": {
    "properties": {
      "field1": {
        "type": "nested",
        "properties": {
          "val": {
            "type": "integer"
          }
        }
      }
    }
  }
}

```

---

<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:** [December 11, 2019, 10:09am UTC](https://discuss.elastic.co/t/mapping-array-of-arrays-that-have-mapped-fields/207417/3 "2019-12-11T10:09:23Z")

</div>

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