【问题标题】:enable groovy scripting on elasticsearch在 elasticsearch 上启用 groovy 脚本
【发布时间】: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","re​​ason":"类型 [indexed]、操作 [search] 和 lang [groovy] 的脚本被禁用"},{ "type":"script_exception","re​​ason":"类型 [indexed]、操作 [search] 和 lang [groovy] 的脚本被禁用"},{"type":"script_exception","re​​ason":"脚本类型 [indexed]、操作 [search] 和 lang [groovy] 被禁用"},{"type":"script_exception","re​​ason":"类型 [indexed]、操作 [search] 和 lang [groovy] 的脚本是disabled"},{"type":"script_exception","re​​ason":"类型 [indexed]、操作 [search] 和 lang [groovy] 的脚本被禁用"},{"type":"script_exception","re​​ason ":"类型 [indexed]、操作 [search] 和 lang [groovy] 的脚本被禁用"},{"type":"script_exception","re​​ason":"类型 [indexed]、操作 [search] 和lang [groovy] 被禁用"},{"type":"script_exception","re​​ason":"类型 [indexed]、操作 [search] 和 lang [groovy] 的脚本被禁用"},{"type":" script_exception","原因":"脚本[indexed] 类型、操作 [search] 和 lang [groovy] 被禁用"},{"type":"script_exception","re​​ason":"类型 [indexed]、操作 [search] 和 lang [groovy] 的脚本已禁用"},{"type":"script_exception","re​​ason":"类型 [indexed]、操作 [search] 和 lang [groovy] 的脚本已禁用"},{"type":"script_exception"," reason":"[indexed] 类型的脚本,操作 [search] 和 lang [groovy] 被禁用"},{"type":"script_exception","re​​ason":"[indexed] 类型的脚本,操作 [search]和 lang [groovy] 被禁用"},{"type":"script_exception","re​​ason":"类型 [indexed]、操作 [search] 和 lang [groovy] 的脚本被禁用"},{"type": "script_exception","re​​ason":"类型 [indexed]、操作 [search] 和 lang [groovy] 的脚本被禁用"}

从日志看来,groovy 没有启用。

谁能帮忙配置一下。

还请帮助我如何使用 groovy 在 elasticsearch 中编写动态?

我正在使用以下链接在 elasticsearch 中启用 groovy 脚本

https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html.

【问题讨论】:

标签: elasticsearch groovy


【解决方案1】:

更新配置后需要重启elasticsearch。

【讨论】:

  • 在多次设置和重启后遇到了同样的问题。我不认为无法重新加载配置文件是问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-31
相关资源
最近更新 更多