疲劳是最舒适的枕头,努力工作吧。

使用script老是报错

Elasticsearch | 作者 wssmao | 发布于2018年09月12日 | 阅读数:2328

想要在reindex时,如果testNull字段为空,就赋一个默认值。
"script": {
"source": "if (ctx._source.testNull == null ) {ctx._source.testNull = "test2"}",
"lang": "painless"
}

老是报(这个符号解析有问题。
已邀请:

ygm

赞同来自: wssmao

POST _reindex
{
  "source": {
    "index": "my_index_v9"
  },
  "dest": {
    "index": "my_index_v9_tmp"
  },
  "script": {
    "lang": "painless",
    "inline": "if(ctx._source.enterpriseCategoryId==null){ctx._source.enterpriseCategoryId=224444}"
  }
}
亲测,没毛病。
before-update.png
  my_index_v9 的数据
updated.png
reindex my_index_v9_tmp 的数据

elasticStack - 90后it大数据男

赞同来自:

~]@D`M([4G0RWJ{JT92VZD8.png

 

God_lockin

赞同来自:

参数没写?

要回复问题请先登录注册