【发布时间】:2016-04-14 19:03:20
【问题描述】:
尝试使用范围查询进行“精确”日期匹配但没有成功。
我有下面映射的agreement_start_date 字段
"agreement_start_date" : {
"type" : "date",
"format" : "strict_date_optional_time||epoch_millis"
}
我已为单个文档编制索引,并且似乎已编制索引。
curl "localhost:9200/cr/_search?pretty=true" -d ''
{
"took" : 35,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "cr",
"_type" : "agreement_index",
"_id" : "570fe59b7f9e6f7f762129ed",
"_score" : 1.0,
"_source":{"agreement_start_date": "2016-04-14T18:46:51.268176+00:00"}
}
}
我想通过将agreement_start_date 与特定日期匹配的简单查询来获取此记录。
{
"query": {
"bool": {
"must": {
"range": {
"agreement_start_date": {
"gte": "2016-04-14",
"lte": "2016-04-14",
"format": "yyyy-MM-dd"
}
}
}
}
}
}
此查询返回 0 个结果。如何在弹性搜索中进行查询,只比较提供的日期部分?
【问题讨论】:
标签: elasticsearch