gpt4 book ai didi

java - 如何在 Elasticsearch 中获取嵌套对象?

转载 作者:行者123 更新时间:2023-12-01 09:45:05 26 4
gpt4 key购买 nike

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 结构,我想获取爱好下的描述为“园艺”的所有记录。

我是 Elasticsearch 新手,如果有人知道请帮助我。

“描述”:“园艺”

最佳答案

这是您的查询:

{
"query": {
"nested": {
"path": "hobbies",
"query": {
"match": {
"hobbies.description": "Gardening"
}
}
}
}
}

关于java - 如何在 Elasticsearch 中获取嵌套对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38122120/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com