linux curl 编写一个新增elasticsearch script 的示例
以下是一个使用curl命令向elasticsearch添加一个新的script的示例:
curl -X POST "localhost:9200/_scripts/my_script" -H 'Content-Type: application/json' -d'
{
"script": {
"lang": "painless",
"source": "ctx._source.message = params.message",
"params": {
"message": "Hello, Elasticsearch!"
}
}
}
'
这个示例中,我们使用curl命令向elasticsearch的_scripts端点发送一个POST请求,创建一个名为my_script的新script。script的语言是painless,source字段定义了脚本的内容,它会将message参数的值赋给文档的message字段。
你可以根据自己的需求修改script的语言、脚本内容和参数。
原文地址: https://www.cveoy.top/t/topic/ic2c 著作权归作者所有。请勿转载和采集!