【问题标题】:Elasticsearch Dynamic Scripting DisabledElasticsearch 动态脚本已禁用
【发布时间】:2015-11-10 15:54:06
【问题描述】:

我正在尝试以下聚合查询:

aggs:{
    total:{
        sum:{
            script: "doc['comments'].value + doc['likes'].value + doc['shares'].value"
        }   
    }
}

它会抛出以下异常:

ScriptException[dynamic scripting disabled]

知道如何解决这个问题。参考:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-sum-aggregation.html

【问题讨论】:

  • 对于 Elasticsearch 2.x.x 使用 script.inline: on script.indexed: on

标签: elasticsearch


【解决方案1】:

默认情况下,在elasticsearch中动态脚本是禁用的,我们需要在elasticsearch.yml文件中添加以下行:

script.disable_dynamic: false

参考:http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.5/modules-scripting.html#_enabling_dynamic_scripting

我们还需要确保在启用动态脚本时,elasticsearch 端口是不公开的。特别是节点用于通信的端口。 (默认为 9300) 否则存在安全漏洞,攻击者可以加入集群进行端口扫描或DDOS攻击。

更新

对于 ES 版本 1.6+

可以通过以下设置为每个脚本引擎启用基于其源的脚本,这些设置需要添加到每个节点上的 config/elasticsearch.yml 文件中。

script.inline: on
script.indexed: on

参考:https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#enable-dynamic-scripting

【讨论】:

  • 该设置在 elasticsearch 2.0 中不再被识别。相反,请使用:script.inline: on script.indexed: on
  • 即使进行了这些更改,我仍然无法运行 function_score 查询,我总是收到以下错误:Parse Failure [No parser for element [function_score]]。有什么想法吗?
  • 也许是stackoverflow.com/questions/23474216/…。你能分享你的具体查询吗?如果您发布一个关于它的新问题并在 cmets 中添加指向该问题的链接,那就更好了。
  • 我使用 ElasticSearch 1.4.4:我添加了三行(script.disable_dynamic: falsescript.inline: onscript.indexed: on)但它仍然不起作用。错误消息:scripts of type [inline], operation [search] and lang [python] are disabled ...有什么想法吗?
  • @cherah30 ElasticSearch 1.4.4?我的想法是升级!
猜你喜欢
  • 2016-12-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-04
  • 1970-01-01
  • 2017-10-12
  • 1970-01-01
相关资源
最近更新 更多