0
好吧,今天我有一個問題來篩選彈性搜索查詢與雙嵌套不相關的字段specs.value.text
和specs.spec.text
。Elasticsearch |過濾不相關的嵌套數據
這些領域的映射:
...
"specs": {
"type": "nested",
"properties": {
"spec": {
"type": "nested",
"properties": {
"text": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
},
"value": {
"type": "nested",
"properties": {
"text": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
....
的問題是,當我想爲過濾與這個請求查詢:
{
"query": {
"filtered": {
"filter": {
"and": {
"filters": [
{
"nested": {
"filter": {
"nested": {
"filter": {
"match": {
"specs.value.text": "10"
}
},
"path": "specs.value"
}
},
"path": "specs"
}
},
{
"nested": {
"filter": {
"nested": {
"filter": {
"match": {
"specs.spec.text": "Délai de livraison"
}
},
"path": "specs.spec"
}
},
"path": "specs"
}
}
]
}
},
"query": {
"match_all": {}
}
}
},
"_source": [
"specs"
]
}
Elasticsearch將返回一個包含specs.spec.text
字Délai de livraison
文件OR10
in specs.value.text
爲例結果: 第一個對象:
...
"specs": [
{
"value": [
{
"text": "10",
"lang": "fr-FR"
}
],
"spec": [
{
"text": "Délai de livraison",
"lang": "fr-FR"
}
]
},
{
"value": [
{
"text": "10",
"lang": "fr-FR"
}
],
"spec": [
{
"text": "Volume",
"lang": "fr-FR"
}
]
}
]
...
第二個目的:
...
"specs": [
{
"value": [
{
"text": "7"
}
]
"spec": [
{
"text": "Délai de livraison"
}
]
}
]
...