2017-05-24 58 views
0

我在Elasticsearch中上传索引时遇到了问题。映射索引Elasticsearch时间戳自定义

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

我得到这个错误:

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

为什么我的curl命令错了吗?

谢谢。

+0

的可能的复制[Elasticsearch:根映射定义具有不支持的参数指标:不是\ _analyzed(https://stackoverflow.com/questions/39288997/elasticsearch -root-mapping-definition-has-unsupported-parameters-index-not-a) –

回答

1

你缺少类型声明:

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

你说得对。事实上,我已经纠正它:curl -H“Content-Type:application/json”-XPUT http:// localhost:9200/technogym_error_timeline -d“{\”mappings \“:{\”_ default _ \“:{\”属性\ “:{\” 时间戳\ “:{\” 类型\ “:\” 日期\ “\ ”格式\“:\ ”YYYY-MM-DD \“}}}}}”。谢谢 –

+0

很高兴帮助。 – Val