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

  • A+
所属分类:全文检索

elasticsearch7.3报错[script] unknown field

, 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
    }
  }
}

 

 

ZPY

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: