How to add mapping for an array field?

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

Hi,

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

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.