Filippo Leoncini
Filippo Leoncini

Reputation: 355

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.

Upvotes: 0

Views: 568

Answers (1)

Val
Val

Reputation: 217554

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

Upvotes: 1

Related Questions