提问:布和纸怕什么?

nested 多层嵌套查询,依次返回命中结果的每一层,而不是命中的根下所有的内容

Elasticsearch | 作者 chao03 | 发布于2018年01月09日 | 阅读数:4940

学校--->年级--->班级---->学生
"mappings": {
"school": {
"_all": {"enabled": false},
"properties": {
"schoolid": {"type": "short"},
"schoolname": {"type": "text"},
"area": {"type": "text"},
"grades": {
"type": "nested",
"properties": {
"gradeid": {"type": "short"},
"gradename": {"type": "text"},
"classnum": {"type": "short"},
"classes": {
"type": "nested",
"properties": {
"classid": {"type":"short"},
"classname": {"type":"text"},
"stunum": {"type": "short"},
"students": {
"type": "nested",
"properties": {
"stuid": {"type":"short"},
"stuname": {"type":"text"},
"stuage": {"type":"short"}
}
}
}
}
}
}
}
}
}
这样的一个mapping,根据查询条件命中了一个student,怎样才能只返回对应的student,对应的class,对应的grade。当前返回的是命中的student所属的school下的所有数据。加入inner_hits后,又仅仅只返回命中的student
已邀请:

CurryQin

赞同来自:

你这个不应该反向来存储嘛  存一个学生,但是学生属于哪个班级,哪个学校

要回复问题请先登录注册