【发布时间】:2014-05-02 06:43:32
【问题描述】:
我一直使用 Elasticsearch 作为我的数据存储,其中有很多文档。我的问题是,我发现 Elasticsearch 忽略了映射日期字段的月份部分。
这是我的索引和查询中的内容,如果我错了,请告诉我:
curl -XPUT 'http://localhost:9200/tt6/' -d '{}'
curl -XPUT 'http://localhost:9200/tt6/tweet/_mapping' -d '{"tweet" : {"properties" : {"date" : {"type" : "date", "format": "YYYY-MM-DD HH:mm:ss" }}}}'
curl -XPUT 'http://localhost:9200/tt6/tweet/1' -d '{"date": "2014-02-14 04:00:45"}'
curl -XGET 'http://localhost:9200/tt6/_search' -d '
{
"query": {
"bool": {
"must": [
{
"range": {
"tweet.date": {
"from": "2014-12-01 00:00:00",
"to": "2014-12-30 00:00:00"
}
}
}
],
"must_not": [],
"should": []
}
},
"from": 0,
"size": 10,
"sort": [],
"facets": {}
}'
我的回答是
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "tt6",
"_type": "tweet",
"_id": "1",
"_score": 1,
"_source": {
"date": "2014-02-14 04:00:45",
"name": "test"
}
}
]
}
}
对于给定的日期范围,在 2014 年 12 月 1 日和 2014 年 12 月 30 日之间应该没有响应,但 Elasticsearch 会返回范围之外的条目。为什么会这样?
【问题讨论】:
标签: elasticsearch