[英]enable groovy scripting on elasticsearch
我正在尝试在弹性搜索中启用groovy脚本。
我用以下几行更新了我的elasticsearch.yml文件
script.inline: true
script.groovy.sandbox.enabled: true
script.inline: on
script.indexed: on
script.search: on
script.engine.groovy.inline.aggs: on
script.engine.groovy.inline.search: on
然后我用这个制作了一个脚本
curl -XPOST localhost:9200/_scripts/groovy/indexedCalculateScore -d '{
"script": "log(_score * 2) + my_modifier"
}'
并尝试使用来访问它:
curl -XPOST localhost:9200/_search -d '{
"query": {
"function_score": {
"query": {
"match": {
"body": "foo"
}
},
"functions": [
{
"script_score": {
"script": {
"id": "indexedCalculateScore",
"lang" : "groovy",
"params": {
"my_modifier": 8
}
}
}
}
]
}
}
}'
我正在关注异常
{“ error”:{“ root_cause”:[{“ type”:“ script_exception”,“ reason”:“类型为[indexed],操作[search]和lang [groovy]的脚本”},{“ type” :“” script_exception“,” reason“:”类型[indexed],操作[search]和lang [groovy]的脚本“},{” type“:” script_exception“,” reason“:” [indexed类型的脚本],操作[search]和lang [groovy]已禁用“},{” type“:” script_exception“,” reason“:”类型[indexed],操作[search]和lang [groovy]类型的脚本“} ,{“ type”:“ script_exception”,“ reason”:“类型为[indexed],操作[search]和lang [groovy]的脚本”},{“ type”:“ script_exception”,“ reason”:“类型为[indexed],操作[search]和lang [groovy]的脚本“},{” type“:” script_exception“,”原因“:”类型为[indexed],操作[search]和lang [groovy的脚本]被禁用“},{” type“:” script_exception“,” reason“:”类型为[indexed],操作[search]和lang [groovy]的脚本“},{” type“:” script_exception“, “原因”:“的脚本 类型[indexed],操作[search]和lang [groovy]被禁用“},{” type“:” script_exception“,” reason“:”类型[indexed],操作[search]和lang [groovy]的脚本{“ type”:“ script_exception”,“ reason”:“已禁用[indexed],操作[search]和lang [groovy]类型的脚本”},{“ type”:“ script_exception”,“原因“:” [indexed]类型的脚本,操作[search]和lang [groovy]被禁用“},{” type“:” script_exception“,” reason“:” [indexed]类型的脚本,操作[search]和lang [groovy]被禁用“},{” type“:” script_exception“,” reason“:”类型为[indexed],操作[search]和lang [groovy]的脚本“},{” type“:” script_exception“,”原因“:”类型[索引],操作[搜索]和语言[常规]的脚本已禁用“}
从日志看来,groovy没有启用。
任何人都可以帮助配置。
还请帮忙,因为我如何使用Groovy在Elasticsearch中编写动态代码?
我正在使用以下链接来在Elasticsearch中启用groovy脚本
https://www.elastic.co/guide/zh-CN/elasticsearch/reference/current/modules-scripting.html 。
更新配置后,您需要重新启动elasticsearch。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.