简体   繁体   中英

How to add a list to Elasticsearch mapping

I have the following JSON format and want to create a mapping for it from Elasticsearch console:

{
  "properties": {
    "@timestamp" : {
     "type" : "date"
    },
    "list": [
      {
        "name": "John",
        "age": "37",
        "title": "Tester"
      }
    ]
  }
}

There's no list or array type in ES, you simply declare objects and then you can add a list of those objects to your documents:

PUT your-index
{
   "mappings": {
      "properties": {
         "@timestamp" : {
            "type" : "date"
         },
         "list": {
            "type": "object",
            "properties": {
               "name": {
                  "type": "text"
               },
               "age": {
                  "type": "integer"
               },
               "title": {
                  "type": "text"
               }
            }
         }
      }
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM