Monday, 26 October 2015

Elasticsearch date type

Date maps JSON string to date type. All dates are UTC and internally mapped to long value.
For all the predefined date formats

Delete employee type if is there any…

DELETE /organization/_mapping/employee

PUT /organization/_mapping/employee
{
 "employee":{
  "properties" : {
   "firstName" : {"type" : "string", "store" : true},
   "lastName" : {"type" : "string", "store" : true},
   "salary" : {"type" : "double", "store" : true},
   "isPermanent" : {"type" : "boolean", "store" : true},
   "joiningDate" : {"type" : "date", "format" : "yyyyMMdd"}
  }
 }
}
You can check the mapping like below.

GET /organization/_mapping/employee
You will get following response.
{
   "organization": {
      "mappings": {
         "employee": {
            "properties": {
               "firstName": {
                  "type": "string",
                  "store": true
               },
               "isPermanent": {
                  "type": "boolean",
                  "store": true
               },
               "joiningDate": {
                  "type": "date",
                  "format": "yyyyMMdd"
               },
               "lastName": {
                  "type": "string",
                  "store": true
               },
               "salary": {
                  "type": "double",
                  "store": true
               }
            }
         }
      }
   }
}



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment