我正在使用Elasticsearch 6.4。我需要对嵌套类型执行日期范围查询。我的映射是:
"items": {
"type": "nested",
"properties": {
"date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"value": {
"type": "long"
}
}
}
items
的示例数据为:
"items": [{"value": 53.79585560271698,"date": "2018-10-30 07:30:00"
},
{"value": 53.15659716175469,"date": "2018-10-30 07:45:00"
},
{"value": 52.13847544211876,"date": "2018-10-30 08:00:00"
},
{"value": 51.30296218052354,"date": "2018-10-30 08:15:00"
},
{"value": 50.9705640874663,"date": "2018-10-30 08:30:00"
},
{"value": 51.37812337892956,"date": "2018-10-30 08:45:00"
},
{"value": 51.162125032933545,"date": "2018-10-30 09:00:00"
}................etc]
我使用了查询:
{
"query":{
"bool":{
"must":[
{
"match":{
"objectId":2078
}
},
{
"nested":{
"path":"items",
"query":{
"bool":{
"must":[
{
"range":{
"items.date":{
"gte":"2018-10-30 07:30:00",
"lte":"2018-10-30 08:30:00"
}
}
}
]
}
}
}
}
]
}
}
}
但是结果没有按照我给定的日期范围进行过滤。我搜索了这个查询,但是解决方案不适用于我。 我是ES的新手。请给我解决方法。