第一步
字段类型设置为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
原文:https://www.cnblogs.com/kiancyc/p/14356151.html