在 OpenSearch 中為資料添加排序配置時,我遇到了我想要排序的資料欄位只有空值的情況。OpenSearch 回傳一個錯誤,上面寫著[query_shard_exception] Reason: No mapping found for [MY_NULL_FIELD] in order to sort on. 話雖這么說,如果我添加一個值,那么排序會按預期運行。有沒有解決的辦法?
uj5u.com熱心網友回復:
如果欄位值都null在所有檔案中,則映射中可能不存在該欄位。unmapped_type在排序查詢中使用應該可以。
{
"sort": [
{
"some_missing_field": {
"order": "asc",
"unmapped_type" : "long"
}
}
]
}
uj5u.com熱心網友回復:
您可以在配置索引映射時定義null_value 屬性。
PUT my-index-000001
{
"mappings": {
"properties": {
"status_code": {
"type": "keyword",
"null_value": "NULL"
}
}
}
}
請在配置空值時考慮以下內容。
null_value 需要與欄位的資料型別相同。例如,長欄位不能有字串 null_value。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/437123.html
上一篇:ExcelBYROW排序結果
