简体   繁体   中英

Mapping index Elasticsearch timestamp custom

I have problem with the uploading of index in Elasticsearch.

curl -H "Content-Type: application/json" -XPUT http://localhost:9200/technogym_error_timeline -d "{\"mappings\":{\"timestamp\":{\"type\":\"date\",\"format\":\"yyyy-MM-dd\"}}}"

I get this error:

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters:  [format : yyyy-MM-dd] [type : date]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [timestamp]: Root mapping definition has unsupported parameters:  [format : yyyy-MM-dd] [type : date]","caused_by":{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters:  [format : yyyy-MM-dd] [type : date]"}},"status":400}

Why is my curl command wrong?

Thanks.

You're missing the type declaration:

curl -H "Content-Type: application/json" -XPUT http://localhost:9200/technogym_error_timeline -d '{
   "mappings":{
     "your_type_name": {                <--- add this
         "properties": {                <--- and this
            "timestamp":{
              "type":"date",
              "format":"yyyy-MM-dd"
            }
         }
      }        
   }
}'

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