我正在將我的 Elasticsearch 從 v5.16 遷移到 6.8(以及之后到 7.16),但我對這種型別的請求有一些問題(見下文):在腳本中使用 params['_source'] 我不明白為什么。我在檔案中沒有發現任何重大更改。你能幫我么 ?僅供參考:索引映射不包含“evts”
謝謝
{
"query": {
"bool": {
"must": [
{ "match": { "closed": "false" }
},
{
"script": {
"script": {
"source": "(params['_source']['evts'] !== null) && (params['_source']['evts']).length > 0",
"lang": "painless"
}
}
}
]
}
}}
回應
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 2,
"skipped": 0,
"failed": 3,
"failures": [
{
"shard": 1,
"index": "myIndex",
"node": "XXX",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"(params['_source']['evts'] !== null) && (params['_source']['evts']).length > 0",
" ^---- HERE"
],
"script": "(params['_source']['evts'] !== null) && (params['_source']['piecesJointes']).length > 0",
"lang": "painless",
"caused_by": {
"type": "null_pointer_exception",
"reason": "Cannot invoke \"Object.getClass()\" because \"callArgs[0]\" is null"
}
}
}
]
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
uj5u.com熱心網友回復:
評論摘要:
正如這里所解釋的那樣,自 6.X 版以來,它不再可能在查詢中訪問源以過濾檔案。只有 doc_values 是可訪問的(見這里)。
在沒有腳本的情況下執行此類查詢的干凈方法是添加evts到映射并使用與子句exists組合的查詢。must_not
在這種情況下,由于evts是嵌套欄位,因此可以使用作業查詢
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "evts",
"query": {
"exists": {
"field": "evts"
}
}
}
}
]
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/414390.html
標籤:
