所以,我有以下日期格式,我想在elasticsearch中作为日期字段导入:
2015-01-12T03:00:00
不幸的是,elasticsearch无法通过以下映射识别此格式:
{
"mappings": {
"veenendaal_type_new": {
"properties": {
"1061_Mundo_Sport_Veenendaal": {
"type": "integer"
},
"1076_We_Veenendaal_Bernard_van_Kreelpoort": {
"type": "integer"
},
"1103_V&D_Veenendaal": {
"type": "integer"
},
"1167_Action_Veenendaal": {
"type": "integer"
},
"1171_Speksnijder_Veenendaal": {
"type": "integer"
},
"1178_Ingang_Corridor_t_h_v__C&A_Veenendaal": {
"type": "integer"
},
"1181_Ingang_Corridor_t_h_v__Bart_Smit_Veenendaal": {
"type": "integer"
},
"1183_De_Heren_van_XVII_Veenendaal": {
"type": "integer"
},
"1184_Corridor_t_h_v__CandyShop_Veenendaal": {
"type": "integer"
},
"1186_Corridor_t_h_v__Het_Goudhaantje_Veenendaal": {
"type": "integer"
},
"1188_Takko_Veenendaal": {
"type": "integer"
},
"1212_De_Cultuurfabriek_Veenendaal": {
"type": "integer"
},
"1216_Jac_Hensen_Veenendaal": {
"type": "integer"
},
"1505_Floral_Haircare_Veenendaal": {
"type": "integer"
},
"201_WE_Veenendaal": {
"type": "integer"
},
"940_HEMA_Veenendaal": {
"type": "integer"
},
"Tijdsperiode": {
"type": "date"
}
}
}
}
}
Elasticsearch返回此错误:
MapperParsingException[failed to parse [Tijdsperiode]]; nested: IllegalArgumentException[Invalid format: "2015-01-12T03:00:00" is malformed at "T03:00:00"];
我的问题是,如何才能使此格式(2015-01-12T03:00:00)对弹性搜索有效?
答案 0 :(得分:2)
在索引定义中使用它:
"Tijdsperiode": {
"type": "date",
"format": "yyyy-MM-dd'T'HH:mm:ssZ"
}
或者
"format": "date_time_no_millis"
http://www.elasticsearch.com/docs/elasticsearch/mapping/date_format/
答案 1 :(得分:1)
在php中,像这样:
date("c", $date_string);//ISO 8601 2004-02-12T15:19:21+00:00