How to add a list to Elasticsearch mapping

361 Views Asked by At

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"
      }
    ]
  }
}
1

There are 1 best solutions below

0
Val On BEST ANSWER

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"
               }
            }
         }
      }
   }
}