【发布时间】:2013-01-30 07:26:34
【问题描述】:
鉴于以下映射,我需要获得符合以下条件的结果
- 名字、姓氏、date_of_birth 和 Active = true OR 完全匹配
- 名字、姓氏完全匹配,Active = true 和 1 个电子邮件(可能的倍数)或
- 名字、姓氏、Active = true 和 1 个旅行证件 number 完全匹配
电子邮件和旅行证件可以指代物品的集合。
{
"profile":{
"properties":{
"date_of_birth":{
"type":"date",
"store":"no"
},
"first_name":{
"type":"string",
"store":"no"
},
"last_name":{
"type":"string",
"store":"no"
},
"email":{
"type":"string",
"store":"no"
},
"active":{
"type":"string",
"store":"no"
},
"travel_document":{
"properties" : {
"countryOfCitizenship" : {"type" : "string"},
"countryOfIssue" : {"type" : "string"},
"expirationDate" : {"type" : "date"},
"nationality" : {"type" : "string"},
"number" : {"type" : "string"},
"addressLines" : {"type": "string"},
"issuedForAreaCode" : {"type": "string"},
"type" : {"type": "string"}
}
}
}
}
}
有没有办法可以在 elasticsearch 中执行这种搜索?我可以用Nested Queries 做到这一点吗?
【问题讨论】: