【发布时间】:2015-07-01 22:18:46
【问题描述】:
我已经创建了一个这样的索引:
PUT twitter
PUT twitter/_mapping/myType
{
"myType" : {
"properties" : {
"message" : {"type" : "date",
"date_detection": true,
"store" : true }
}
}
}
然后我放了几个文件:
POST twitter/myType
{
"message":123456
}
我有此文档和其他带有 message 值的文档:“123456”、-123456、“2014-01-01”、“-123456”(注意此处的字符串和数字差异)。只有值为“12@3454”的文档未能放置。
所以现在我执行:
GET twitter/myType/_search?pretty=true&q=*:*
结果是:
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 4,
"max_score": 1,
"hits": [
{
"_index": "twitter",
"_type": "myType",
"_id": "AU5JvFsHvhUOO_5MdfCv",
"_score": 1,
"_source": {
"message": -123456
}
},
{
"_index": "twitter",
"_type": "myType",
"_id": "AU5Ju6aOvhUOO_5MdfCs",
"_score": 1,
"_source": {
"message": "123456"
}
},
{
"_index": "twitter",
"_type": "myType",
"_id": "AU5Ju0KOvhUOO_5MdfCq",
"_score": 1,
"_source": {
"message": "2014-01-01"
}
},
{
"_index": "twitter",
"_type": "myType",
"_id": "AU5JvDiGvhUOO_5MdfCu",
"_score": 1,
"_source": {
"message": "-123456"
}
}
]
}
}
为什么我在日期字段而不是字符串值中获取这些值 - ISODateTimeFormat.dateOptionalTimeParser?有没有办法以一种格式(例如字符串或毫秒)获取所有日期?
Elasticsearch 版本为 1.4.3
【问题讨论】:
-
您是否尝试在映射的消息属性中显式设置格式,例如
format: 'dateOptionalTime'
标签: date datetime elasticsearch