【发布时间】:2020-11-21 01:23:30
【问题描述】:
我使用的是 Elasticsearch 7.2.0 版,并且在我的映射中具有以下类型:
"status_change": {
"type": "object",
"enabled": false
},
该字段内的数据示例:
"before": {
"status_type": "Status One"
},
"after": {
"status_type": "Status Two"
}
有各种状态类型,我正在尝试创建一个查询来识别从状态类型之前指定到状态类型之后指定的更改。我正在努力通过这些嵌套元素进行查询,但以下查询失败:
{
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"nested": {
"path": "status_change",
"query": {
"term": {
"status_change.before": "the_before_status"
}
}
}
}
}
}
}
与:
"caused_by" : {
"type" : "illegal_state_exception",
"reason" : "[nested] nested object under path [status_change] is not of nested type"
}
这是不言自明的,因为 status_change 不是“嵌套”字段。我曾尝试通过嵌套元素来搜索对象,但没有找到解决方案。
有没有办法让我像这样搜索嵌套的对象元素?
【问题讨论】:
标签: elasticsearch