Iam storing in elastic like this
{
"user":{
"name":"Johnson",
"age":29,
"education":[
{
"school":"STE college",
"year":2017,
"qualification":"Phd",
"isRecent":1
},
{
"school":"business school",
"year":2015,
"qualification":"Mba",
"isRecent":0
},
{
"school":"saint school",
"year":2013,
"qualification":"Btech",
"isRecent":0
}
]
}
}
我需要获得年龄为29岁的查询数据,并将学校作为" STE大学"只有教育最近的地方(学校=" STE大学"同一嵌套对象的isRecent = 1)
答案 0 :(得分:0)
很大程度上取决于您的映射,但假设school
被映射为文本和关键字,这应该有效:
{
"query" : {
"bool" : {
"must" : [
{"term" : {"user.age" : "29"}},
{"term" : {"user.education.school.keyword" : "STE college"}},
{"term" : {"user.education.isRecent" : "1"}}
]
}
}
}