我收到以下异常:
ElasticsearchParseException[failed to parse date field [2016-02-20T22:00:00.000Z], tried both date format [dateOptionalTime], and timestamp number]; nested: IllegalArgumentException[Invalid format: \"2016-02-20T22:00:00.000Z\"]
在以下查询中:
curl -XGET https://xxxx.us-east-1.es.amazonaws.com/yyy/zzz/_search?pretty=true -d '
{
"size": 0,
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"range": {
"event_timestamp": {
"gte": "2016-02-20T22:00:00.000Z",
"lte": "2016-02-27T22:00:00.000Z"
}
}
}
]
}
}
}
}
}
'
event_timestamp映射为:
"event_timestamp":{"type":"date","format":"dateOptionalTime"}
样本条目为:
{
"_index" : "yyy",
"_type" : "zzz",
"_id" : "abcde",
"_score" : 1.0,
"_source":{"event":"xxx","client_timestamp":"1456347863865","event_timestamp":"2016-02-24T21:04:23.495Z","partitionKey":"xxx"}
最佳答案
我最终以毫秒为单位发送时间,因为这似乎是ES愿意在这种特定情况下接受的唯一格式。
如果有人有任何建议,我很乐意听取其他选择。
所以这确实起作用:
curl -XGET https://xxxx.us-east-1.es.amazonaws.com/yyy/zzz/_search?pretty=true -d '
{
"size": 0,
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"range": {
"event_timestamp": {
"gte": 1456005600000,
"lte": 1456610400000
}
}
}
]
}
}
}
}
}
'
关于date - 解析日期上的 Elasticsearch 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35718335/