我正在尝试使用日期格式索引数据Tue May 14 17:06:01 PDT 2013
。正如 Elasticsearch 中所述日期格式 http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html文档我需要使用自定义日期格式。我指的是日期时间格式 http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormat.html文件和各自的格式是E M d H:m:s z Y
.
我能够创建映射,但是当我尝试索引数据时,它给了我错误。
映射:-
{
"tweet": {
"properties": {
"user": {
"type": "string",
"index": "not_analyzed"
},
"message": {
"type": "string",
"null_value": "na"
},
"postDate": {
"type": "date",
"format": "E M d H:m:s z Y"
},
"priority": {
"type": "integer"
},
"rank": {
"type": "float"
}
}
}
}
索引文件:-
curl -XPUT 'http://localhost:9200/tweets/tweet/1' -d '{
"user" : "kimchy",
"message" : "This is a tweet!",
"postDate" : "Tue May 14 17:06:01 PDT 2013",
"priority" : 4,
"rank" : 12.3
}'
Error:-
{"error":"MapperParsingException[failed to parse [postDate]];
nested: MapperParsingException[failed to parse date field [Tue May 14 17:06:01 PDT 2013],
tried both date format [E M d H:m:s z Y], and timestamp number with locale []];
nested: IllegalArgumentException[Invalid format: \"Tue May 14 17:06:01 PDT 2013\"
is malformed at \"May 14 17:06:01 PDT 2013\"]; ","status":400}
有什么建议吗?