ZPY博客

elasticsearch7.3报错[script] unknown field [file], parser not found

elasticsearch7.3报错[script] unknown field [file], parser not found

原因:高版本的elasticsearch不支持file类型,也就是说不支持从外部文件读取脚本

解决方法:

1.需要先将脚本post到es的库中

POST _scripts/caculate-price
{
  "script":{
    "lang":"painless",
    "source": "ctx._source.price += params.new_price"
  }
}

2.根据id来调用

POST test_index/product/1/_update
{
  "script":{
    "id":"caculate-price",
    "params": {
      "new_price": 22
    }
  }
}