【发布时间】:2017-07-28 19:24:04
【问题描述】:
我正在尝试在我的弹性搜索中启用 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] 的脚本是disabled"},{"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","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] 的脚本被禁用"}
从日志看来,groovy 没有启用。
谁能帮忙配置一下。
还请帮助我如何使用 groovy 在 elasticsearch 中编写动态?
我正在使用以下链接在 elasticsearch 中启用 groovy 脚本
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html.
【问题讨论】:
-
请注意,在 6.x 版本中已删除 groovy 支持:elastic.co/guide/en/elasticsearch/reference/6.x/…
标签: elasticsearch groovy