runtimeerror php,elasticsearch-php upsert 总是提示runtime error?

版本

Elasticsearch version:5.1

Elasticsearch-php version: 5.0

upsert

文档是:

array(6) {

["_index"]=>

string(4) "demo"

["_type"]=>

string(4) "demo"

["_id"]=>

string(1) "1"

["_version"]=>

int(5)

["found"]=>

bool(true)

["_source"]=>

array(4) {

["a"]=>

int(3)

["b"]=>

string(1) "a"

["c"]=>

string(1) "b"

["d"]=>

array(2) {

[0]=>

string(1) "a"

[1]=>

string(1) "b"

}

}

}

然后我执行下面的代码:

require_once './vendor/autoload.php';

$client = Elasticsearch\ClientBuilder::create();

$client->setHosts(['127.0.0.1']);

$client = $client->build();

print_r($client->update([

'index' => 'demo',

'type' => 'demo',

'id' => 1,

'body' => [

'script' => 'ctx._source.counter += 4',

'params' => [

'count' => 4

],

'upsert' => [

'counter' => 1

]

]

]));

提示我:

Fatal error: Uncaught Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"remote_transport_exception","reason":"[shcGs0R][127.0.0.1:9300][indices:data/write/update[s]]"}],"type":"illegal_argument_exception","reason":"failed to execute script","caused_by":{"type":"script_exception","reason":"runtime error","caused_by":{"type":"null_pointer_exception","reason":null},"script_stack":["ctx._source.counter += 4"," ^---- HERE"],"script":"ctx._source.counter += 4","lang":"painless"}},"status":400}

print_r($client->update([

'index' => 'demo',

'type' => 'demo',

'id' => 1,

'body' => [

'script' => 'ctx._source.a += params.count',

'params' => [

'count' => 4

],

]

]));

这个也提示这个错误:

Fatal error: Uncaught Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"remote_transport_exception","reason":"[shcGs0R][127.0.0.1:9300][indices:data/write/update[s]]"}],"type":"illegal_argument_exception","reason":"failed to execute script","caused_by":{"type":"script_exception","reason":"runtime error","caused_by":{"type":"null_pointer_exception","reason":null},"script_stack":["ctx._source.a += params.count"," ^---- HERE"],"script":"ctx._source.a += params.count","lang":"painless"}},"status":400}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值