【发布时间】:2017-10-11 07:13:23
【问题描述】:
我有一个弹性搜索索引,映射如下:
{
"issues": {
"mappings": {
"issues": {
"properties": {
"captured_by": {
"type": "long"
},
"captured_on": {
"type": "date",
"format": "dateOptionalTime"
},
"description": {
"type": "string"
},
"id": {
"type": "string",
"index": "not_analyzed"
},
"updated_at": {
"type": "date",
"format": "dateOptionalTime"
}
"issue_org_states": {
"type": "nested",
"properties": {
"assigned_at": {
"type": "date",
"format": "dateOptionalTime"
},
"assigned_by": {
"type": "long"
},
"updated_at": {
"type": "date",
"format": "dateOptionalTime"
},
"updated_by": {
"type": "long"
}
}
}
}
}
}
}
}
并填充一个文档如下:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "issues",
"_type": "issues",
"_id": "13f3bf09-08cb-4464-b326-15872bdb0870",
"_score": 1,
"_source": {
"id": "13f3bf09-08cb-4464-b326-15872bdb0870",
"description": "Sloppy paint job",
"captured_on": "2017-10-09T09:24:01.928Z",
"captured_by": 1,
"updated_at": "2017-10-09T12:47:22.982Z",
"issue_org_states": [
{
"updated_at": "2017-10-09T12:47:22.982Z",
"updated_by": 1,
"assigned_at": "2017-10-09T12:47:22.982Z",
"assigned_by": 1879048240
}
]
}
}
]
}
}
我想查询属性assigned_at 和updated_at 上的路径“issues.issue_org_states”。 查询如下:
{
"query": {
"nested": {
"path": "issue_org_states",
"range": {
"assigned_at": {
"from": "2017-10-09T00:00:00.000Z",
"to": "2017-10-09T23:59:59.999Z",
"include_lower": true,
"include_upper": true
}
}
}
}
}
当我在上面运行时查询它的返回数据。但是,如果在 updated_at 而不是 assignment_at 上运行相同的查询,则弹性搜索返回 0 结果。 assign_at 和 updated_at 都具有相同的映射和相同的数据,直到下面的查询不返回任何结果。
{
"query": {
"nested": {
"path": "issue_org_states",
"range": {
"updated_at": {
"from": "2017-10-09T00:00:00.000Z",
"to": "2017-10-09T23:59:59.999Z",
"include_lower": true,
"include_upper": true
}
}
}
}
}
如果我在这里遗漏了什么,请帮忙。
【问题讨论】:
标签: elasticsearch