[英]how to fetch nested object in elastic search?
How can i fetch nested object in elastic search ?
{
"_index": "userinfo",
"_type": "userdetails",
"_id": "2",
"_score": 1,
"_source": {
"id": "2",
"name": "Robert Mark",
"age": 42,
"email": "robert.mark@ceb.com",
"userType": {
"id": "3",
"type": "End User"
},
"hobbies": [
{
"id": "3",
"description": "Writing Books"
},
{
"id": "4",
"description": "Gardening"
}
]
}
}
这是我的json结构,我想获取所有记录中爱好描述为“ Gardening”的记录。
我是弹性搜索的新手,如果有人知道,请帮助我。
“ description”:“园艺”
这是您的查询:
{
"query": {
"nested": {
"path": "hobbies",
"query": {
"match": {
"hobbies.description": "Gardening"
}
}
}
}
}
如果您为爱好对象预创建了nested
映射类型, 则 israelst是正确的。 但是默认情况下,它使用object
而不是`nested。
{
"query" : {
"match" : {
"hobbies.description" : "Gardening"
}
}
}
请注意,查询实际上是相同的,实际上,我的示例是嵌套版本的子集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.