学校--->年级--->班级---->学生
"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
"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
1 个回复
CurryQin
赞同来自: