[英]ElasticSearch 5: Search nested field
I have the following document, and it got indexed into ElasticSearch 5.5我有以下文档,它被索引到 ElasticSearch 5.5
{
"dept_id": "DP123",
"related_depts": [
{
"id": "DP222",
"roles": [
{
"status": null,
"persons": [
{
"id": "P123",
"roles": [
{
"status": null
}
]
},
{
"id": "P124",
"roles": [
{
"status": null
}
]
}
]
}
]
}
]
}
Right now, I want to search for all the docs that has persons id=P123 I used the following command to search.现在,我想搜索所有人员 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"
}
}
}
}
}
'
and I'm getting the follwing error.我收到了以下错误。
failed to find nested object under path [related_depts.roles.persons]
All of your objects are inside of arrays.您的所有对象都在数组内。
As such, you'll need to search the first index of each:因此,您需要搜索每个索引的第一个索引:
related_depts[0].roles[0].persons[0]
Hope this helps!希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.