0
我試圖在使用批量更新的ES索引中爲文檔添加建議字段,但我不斷收到NullPointerException作爲響應。這裏是什麼,我試圖做一個例子:使用ES 1.1.1ElasticSearch批量更新中的NullPointerException
命令使用curl
:
curl -s -XPOST "http://www.example.com/test_index/entity/_bulk" --data-binary @tmp
tmp文件裏面:
{"update": {"_type": "entity", "_id": "fbf804af945d13d9b7c076948bc1bd19", "_index": "test_index"}}
{"lang": "js", "params": {"input_name": {"input": ["calcium"]}}, "routing": "434750445cdc9cea954399185e4b3da8", "script": "ctx._source.suggest = input_name"}
我得到這個迴應:
{"error":"NullPointerException[null]","status":500}
但是,如果我做一個正常的更新,它工作正常:
curl -s -XPOST "http://www.example.com/test_index/entity/fbf804af945d13d9b7c076948bc1bd19/_update?routing=434750445cdc9cea954399185e4b3da8" --data-binary @tmp
{
"script": "ctx._source.suggest = input_name",
"params": {
"input_name": {
"input": [
"calcium"
]
}
}
}
這裏是爲實體的映射是這樣的:
entity: {
_parent: {
type: post
}
_routing: {
required: true
}
properties: {
suggest: {
type: completion
analyzer: simple
payloads: false
preserve_separators: true
preserve_position_increments: true
max_input_length: 50
}
type: {
type: string
index: not_analyzed
store: true
}
value: {
type: string
index: not_analyzed
store: true
}
}
}