我正在尝试将日期解析为字符串格式,如月份和数字年份格式,如" JAN,92"。我的映射如下:
size" => 0,
"query" => {
"bool" => {
"must" => [
{
"term" => {
"checkin_progress_for" => {
"value" => "Goal"
}
}
},
{
"term" => {
"goal_owner_id" => {
"value" => "#{current_user.access_key}"
}
}
}
]
}
},
"aggregations" => {
"chekins_over_time" => {
"range" => {
"field" => "checkin_at",
"format" => "MMM, YY",
"ranges" => [
{
"from" => "now-6M",
"to" => "now"
}
]
},
"aggs" => {
"checkins_monthly" => {
"date_histogram" => {
"field" => "checkin_at",
"format" => "MMM, YY",
"interval" => "month",
"min_doc_count" => 0,
"missing" => 0,
"extended_bounds" => {
"min" => "now-6M",
"max" => "now"
}
}
}
}
}
}
}
我抛出以下错误:
elasticsearch.transport.RemoteTransportException:[captia-america] [127.0.0.1:9300] [indices:data / read / search [phase / query]] 引起:elasticsearch.ElasticsearchParseException:无法使用[MMM,YY]格式解析日期字段[0]
如果我删除{MMM,YY}并将正常日期格式设置为有效。 有什么可以解决这个问题的方法。帮助赞赏。
答案 0 :(得分:0)
您的checkins_monthly
聚合有点不对劲。 missing
部分应该具有相同的格式,以便在缺少字段时使用该日期。 0
实际上不是日期。
例如:
"aggs": {
"checkins_monthly": {
"date_histogram": {
"field": "checkin_at",
"format": "MMM, YY",
"interval": "month",
"min_doc_count": 0,
"missing": "Jan, 17",
"extended_bounds": {
"min": "now-6M",
"max": "now"
}
}
}