0
嵌套查詢我有嵌套字段該指數映射:如何使用我疊的搜索條件和在ElasticSearch
"customerpropertieses": {
"_parent": {
"type": "customerprofile"
},
"_routing": {
"required": true
},
"properties": {
"id": {
"type": "string"
},
"parentId": {
"type": "string"
},
"properties": {
"type": "nested",
"properties": {
"extentionPropertyId": {
"type": "long"
},
"propertyName": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
}
}
我想找到customerpropertieses其中propertyName=criteria1 & value=value1 & propertyName=criteria2 & value=value2
查詢我生成這是:
{
"from": 0,
"size": 10,
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"query": {
"nested": {
"query": {
"bool": {
"must": [
{
"match": {
"properties.propertyName": {
"query": "criteria1 "
}
}
},
{
"match": {
"properties.value": {
"boost": 10.0,
"query": "value1"
}
}
},
{
"match": {
"properties.propertyName": {
"query": "criteria2"
}
}
},
{
"match": {
"properties.value": {
"boost": 10.0,
"query": "value2"
}
}
}
]
}
},
"path": "properties",
"inner_hits": {
"explain": false
},
"_name": "nested_properties"
}
}
}
我得到0個結果回來,我肯定有這些特徵的數據。當我看只有propertyName=criteria1 & value=value1
或參數propertyName = criteria2 &值=數值'
的問題是我怎麼可以疊加在嵌套查詢使用&搜索條件搜索工作正常?
umm或許我沒有正確解釋它customerpropertieses.properties是我的C#代碼中的List [Tuple [propertyName,value]]。我希望查詢匹配此列表中的多個項目,即給我所有的customerpropertieses,其中propertyName = tomato和value = red AND propertyName = corn和value = yellow。現在這將返回在列表中有兩個屬性的customerpropertieses:紅番茄和黃色玉米 – Adrian
是的,這正是這個查詢正在做criteria2 value2和criteria1 value1。我添加了兩個嵌套的必須過濾器。 – user3775217
哦,我明白了;所以如果我想匹配4個標準,我需要4個嵌套查詢。正確? – Adrian