【发布时间】:2017-10-18 15:09:43
【问题描述】:
我正在尝试过滤 Elasticsearch 查询 (ES 5.6.2) 中 nested document 中的字段。嵌套文档本身就是主文档内部对象中的一个字段。映射如下所示:
{
"mappings": {
"container": {
"properties": {
"host": {
"properties": {
"tags_nested": {
"type": "nested",
"properties": {
"tag_key": {
"type": "keyword"
},
"tag_val": {
"type": "keyword"
}
}
}
}
}
}
}
}
}
我想过滤host.tags_nested.tag_keys,但我无法找出正确的语法来访问host 内部对象中的嵌套tags_nested 文档。当我知道有一些应该匹配时,我尝试了以下查询,它不返回任何结果:
{
"query": {
"nested": {
"path": "host.tags_nested",
"query": {
"bool": {
"filter": [
{
"term": {
"host.tags_nested.tag_key": "example_key"
}
}
]
}
}
}
}
}
根据ES docs,您可以通过传递与嵌套文档的字段名称对应的path 来执行nested 查询以在嵌套文档中进行查询。但是,当path 位于内部对象中并且需要使用点符号访问时,这似乎不起作用。
有什么想法吗?
【问题讨论】:
标签: elasticsearch elasticsearch-5