我正在尝试使用批量更新向我的ES索引中的文档添加建议字段,但我不断收到NullPointerException作为响应。这是我想要做的一个例子:
使用ES 1.1.1
命令使用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
}
}
}
答案 0 :(得分:0)
在索引映射中,将路由设置为required,因此在更新的cmd部分中需要指定路由参数:
{"update": {"_type": "entity", "_id": "fbf804af945d13d9b7c076948bc1bd19", "_index": "test_index", **** --> "routing: "fbf804af945d13d9b7c076948bc1bd19" }}