2
嵌套方面的值。這代表我的映射:搜索elasticsearch
{
"name": {"type": "string", "include_in_all": true},
"properties": {
"type": "nested",
"properties": {
"name": {"type": "string"},
"value": {"type": "string"}
}
}
如何使用平面式搜索「properties.value」的價值?這裏是一個示例文件:
{
"name": "Testproduct",
"properties": [{
"name": "Color",
"value": "Green"
}, {
"name": "Size",
"value": "M"
}]
}
我想通過「顏色」屬性構建一個facetted列表(僅)。所以結果應該是這樣的:
Red: 7 times
Green: 5 times
Blue: 1 times
這是我到目前爲止已經試過:
{
"size": 1000,
"query": {
"query_string": {
"query": " ... ",
"default_operator": "AND"
}
},
"facets": {
"resolution": {
"nested": "properties",
"facet_filter": {
"term": {
"name": "Color"
}
},
"terms_stats": {
"key_field": "name",
"value_field": "value"
}
}
}
}
如果我執行這個搜索查詢,我得到如下回應:
FacetPhaseExecutionException[Facet [resolution]: value_field [value] isn't a number field, but a string];
我幾乎不明白答案,但我不知道我的概念做錯了什麼。