# How to add mapping for an array field?

**URL:** <https://discuss.elastic.co/t/how-to-add-mapping-for-an-array-field/43725>\
**Category:** Elasticsearch\
**Created:** [March 8, 2016, 2:43am UTC](https://discuss.elastic.co/t/how-to-add-mapping-for-an-array-field/43725 "2016-03-08T02:43:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric](https://avatars.discourse-cdn.com/v4/letter/e/898d66/32.png) [@Eric](https://discuss.elastic.co/u/Eric)\
**Post date:** [March 8, 2016, 2:43am UTC](https://discuss.elastic.co/t/how-to-add-mapping-for-an-array-field/43725/1 "2016-03-08T02:43:35Z")

</div>

Sample document in elasticsearch:

```
{
    "name": "Tom",
    "hobbies": [
        {
            "hobby": "go for a walk"
        },
        {
            "hobby": "board games"
        }
    ]
}

```

Here is mapping added for "name":

```
{
    "person": {
         "_all": {
            "analyzer": "ik_max_word",
            "search_analyzer": "ik_max_word",
            "term_vector": "no",
            "store": "false"
        },
        "properties": {
            "name": {
                "type": "string",
                "store": "no",
                "term_vector": "with_positions_offsets",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_max_word",
                "include_in_all": "true",
                "boost": 8
            }
        }
    }
}

```

Problem: How do I add mapping for hobbies.hobby? I want to specify this field for analyzer -\> ik\_max\_word

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [March 9, 2016, 11:51am UTC](https://discuss.elastic.co/t/how-to-add-mapping-for-an-array-field/43725/2 "2016-03-09T11:51:07Z")

</div>

Hi,

a mapping for this kind of document would look something like this:

```auto
PUT /index_name/
{
  "mappings": {
    "type": {
      "properties": {
        "name": {
          "type": "string",
          "analyzer": "myAnalyzer"
        },
        "hobbies": {
          "properties": {
            "hobby": {
              "type": "string",
              "analyzer": "myAnalyzer"
            }
          }
        }
      }
    }
  }
}

```

This assumes that you have defines an analyzer with the name "myAnalyzer", so it would be "ik\_max\_word" in your 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:** [July 5, 2017, 11:09pm UTC](https://discuss.elastic.co/t/how-to-add-mapping-for-an-array-field/43725/3 "2017-07-05T23:09:54Z")

</div>


