【发布时间】:2017-05-25 06:42:19
【问题描述】:
user_profile 索引具有与属性 country_iso 的分支映射
{
"_index": "user_profile",
"_type": "user",
"_id": "188",
"_score": 1.0042034,
"_source": {
"user_id": 188,
"phone": "971550000322",
"profile_set_date": "Apr 6, 2017",
"phone_country": "AE",
"branches": [
{
"id": 27,
"brand_id": 20,
"country_iso": "KW",
"city_iso": "KW-02-145162",
"area_id": 33
},
{
"id": 45,
"brand_id": 56,
"country_iso": "AE",
"city_iso": "AE-01-206944",
"area_id": 18
},
{
"id": 46,
"brand_id": 56,
"country_iso": "AE",
"city_iso": "AE-01-206944",
"area_id": 18
}
],
"prog_id": 13,
"email": "971550000322@email.com"
}
}
我需要找到使用 country_iso=AE 而没有其他任何东西的分支机构映射的用户
must 和 must_not 组合对我不起作用
{
"query": {
"bool": {
"must": [
{
"match": {
"prog_id": 13
}
}
],
"should": [
{
"nested": {
"path": [
"branches"
],
"query": {
"query_string": {
"fields": [
"branches.country_iso"
],
"query": "AE"
}
}
}
}
],
"minimum_number_should_match": 1,
"must_not": [
{
"bool": {
"must_not": [
{
"nested": {
"path": [
"branches"
],
"query": {
"query_string": {
"fields": [
"branches.country_iso"
],
"query": "AE"
}
}
}
}
]
}
}
]
}
}
}
【问题讨论】:
标签: elasticsearch