第一步 字段类型设置为nested
{
"book": {
"properties": {
"title":{"type":"string"},
"chapters":{
"type":"nested",
"properties":{
"title":{"type":"string"},
"length":{"type":"long"}
}
}
}
}
}
第二步 用inner_hits来查询
POST /bookindex/book/_search
{
"_source": false,
"query": {
"nested": {
"path": "chapters",
"query": {
"match": {
"chapters.title": "epilogue"
}
},
"inner_hits": {}
}
}
}
参考链接:https://stackoverflow.com/questions/16788553/returning-a-partial-nested-document-in-elasticsearch
--结束END--
本文标题: elasticsearch如何搜索嵌套内容
本文链接: https://www.lsjlt.com/news/8195.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0