0
我有一個索引這種形式的項目elasticsearch排序nested_filter不匹配nested_path
{
"_index": "identity-index",
"_source": {
"names": [
"test"
],
"private": {
"lists": [
{
"listId": "56b8a0197f3c56654f8751b5",
"ratings": [
{
"rating": 4,
"authorId": "56499b7a97e3aa857cdc4f1d"
},
{
"rating": 4,
"authorId": "56b36646a24d50866de77928"
},
{
"rating": 4,
"authorId": "56cb16005082871b33ab1a60"
},
{
"rating": 4,
"authorId": "56b216a4c28edca956fe96d4"
},
{
"rating": 4,
"authorId": "56b34e8d8e324180259252f7"
}
]
},
{
"listId": "56c1c508da49cdd9662b102c"
}
]
}
},
"sort": [
"-Infinity"
]
}
我想給一個listId平均等級對它們進行排序:
我已經嘗試了很多辦法和我得到的最接近的是這樣的:
"sort": {
"private.lists.ratings.rating": {
"missing": "_last",
"order": "desc",
"mode": "avg",
"nested_path": "private.lists.ratings",
"nested_filter": {
"term": {
"private.lists.listId": "56c1c508da49cdd9662b102c"
}
}
}
},
問題是,這個分數都是-Inf。我找不到任何方法來排序private.lists.ratings中的嵌套元素,但要考慮private.lists.listId的過濾器。 nested_path和nested_filter字段是不同的,我不認爲它們應該是。
呀一個簡單的列表,我害怕這一點。不幸的是,拼合不是一個解決方案。我正在提供腳本,但似乎無法設計出正確的groovy腳本。 – Tomy