0
我有下面的映射,我試圖查詢最內層的嵌套元素,但它給了我錯誤。在多級嵌套對象中的彈性搜索
映射:
{
"search_v1" : {
"mappings" : {
"statement" : {
"properties" : {
"details" : {
"type" : "text",
},
"source" : {
"type" : "nested",
"properties" : {
"affiliation" : {
"type" : "nested",
"properties" : {
"name" : {
"type" : "text"
}
}
},
"first_name" : {
"type" : "text"
},
"last_name" : {
"type" : "text"
}
}
}
}
}
}
}
}
數據:
{
"_index" : "search_v1",
"_type" : "statement",
"_id" : "AVTHp5y8yr47EGbDlTWu",
"_score" : 1.0,
"_source" : {
"details" : "test test",
"source" : {
"first_name" : "source2",
"last_name" : "source2",
"affiliation" : [ {
"name" : "affiliation1"
}, {
"name" : "affiliation2"
}, {
"name" : "affiliation4"
} ]
}
}
}
查詢:
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "source",
"query": {
"bool": {
"must": [ {
"nested": {
"path": "affiliation",
"query": {
"bool": {
"must": [
{ "match": { "affiliation.name": "affiliation2" }}
]
}}}}
]
}}}}
]
}}}
錯誤: query_shard_exception:無法創建查詢
,如果我嘗試查詢source.first_name然後它可以工作,但是當我嘗試去1級深,它會給出錯誤。
謝謝。
其沒有給予任何結果,單位也是一個嵌套的對象,也可以在源 –
更多然後1點的隸屬關係關於如何使用您的原始查詢,但使用在比賽中完全合格的路徑? '{「match」:{「source.affiliation.name」:「affiliation2」}}' –
yes試過了,但那也行不通 –