我有以下映射:
{
"properties": {
"type": {
"type": "keyword"
},
"body": {
"type": "text"
},
"id": {
"type": "keyword"
},
"date": {
"type": "date"
},
},
}
body 欄位將是一封電子郵件,它很長,我不想索引它。
從索引中排除該欄位的正確方法是什么?
我嘗試了什么:
enabled: false- 正如我從檔案中了解到的那樣,它僅適用于object型別欄位,但在我的情況下,它并不是一個真正的物件,所以我不確定我是否可以使用它。
index: false/'no'- 這完全破壞了代碼,不允許我進行搜索。我的查詢包含查詢本身和帶有過濾器的聚合。過濾器包含范圍:
date: { gte: someDay.getTime(), lte: 'now' }
PS someDay 在我的情況下是某一天。
我在應用 index: false 映射到 body 欄位后得到的錯誤如下:
{
"error":
{
"root_cause":
[
{
"type": "number_format_exception",
"reason": "For input string: \"now\""
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards":
[
{
"shard": 0,
"index": "test",
"node": "eehPq21jQsmkotVOqQEMeA",
"reason":
{
"type": "number_format_exception",
"reason": "For input string: \"now\""
}
}
],
"caused_by":
{
"type": "number_format_exception",
"reason": "For input string: \"now\"",
"caused_by":
{
"type": "number_format_exception",
"reason": "For input string: \"now\""
}
}
},
"status": 400
}
我不確定這些情況是如何關聯的,因為date當我將索引屬性添加到body欄位時,錯誤是關于欄位的。
我在用著:"@opensearch-project/opensearch": "^1.0.2"
請幫助我理解:
- 如何從索引中排除欄位。
- 為什么將 index: false 應用于
body映射中的欄位會破壞代碼,并且我收到與date欄位相關的錯誤。
uj5u.com熱心網友回復:
您只需將映射修改為:
"body": {
"type": "text",
"index": false
}
它應該作業
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/489605.html
上一篇:elasticsearch7.X建議自動編譯如何翻譯成java?
下一篇:近乎實時的彈性搜索查詢統計和分析
