elasticsearch如何搜索嵌套内容
第一步 字段类型设置为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
以上是 elasticsearch如何搜索嵌套内容 的全部内容, 来源链接: utcz.com/z/535387.html