我有以下文档,并将其编入ElasticSearch 5.5
{
"dept_id": "DP123",
"related_depts": [
{
"id": "DP222",
"roles": [
{
"status": null,
"persons": [
{
"id": "P123",
"roles": [
{
"status": null
}
]
},
{
"id": "P124",
"roles": [
{
"status": null
}
]
}
]
}
]
}
]
}现在,我想搜索所有具有persons id=P123的文档,我使用以下命令进行搜索。
curl -XPOST 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"nested" : {
"path" : "related_depts.roles.persons",
"query" : {
"match" : {
"id": "P123"
}
}
}
}
}
'我得到了这个错误。
failed to find nested object under path [related_depts.roles.persons]发布于 2018-02-06 20:46:28
所有的对象都在数组中。
因此,您需要搜索每个索引的第一个索引:
related_depts[0].roles[0].persons[0]希望这能有所帮助!
https://stackoverflow.com/questions/48651624
复制相似问题