Elasticsearch 动态脚本已禁用 [英] Elasticsearch Dynamic Scripting Disabled
问题描述
我正在尝试以下关于聚合的查询:
I am trying the following query on aggregation:
aggs:{
total:{
sum:{
script: "doc['comments'].value + doc['likes'].value + doc['shares'].value"
}
}
}
并抛出以下异常:
ScriptException[禁用动态脚本]
知道如何解决这个问题.参考:
Any idea how can I fix this. Refer:
推荐答案
默认情况下,elasticsearch 中禁用动态脚本,我们需要在 elasticsearch.yml 文件中添加以下行:
By default dynamic scripting is disabled in elasticsearch, we need to add the following line in elasticsearch.yml file:
script.disable_dynamic: false
此外,我们需要确保在启用动态脚本时,elasticsearch 端口不是公开的.特别是节点用于通信的端口.(默认 9300)否则存在安全漏洞,允许攻击者加入集群进行端口扫描或DDOS攻击.
Also we need to make sure when we are enabling dynamic scripting, the elasticsearch ports are not public. specially the port used by nodes for communication. (9300 by default) Otherwise it has security vulnerability and allows attackers to join the cluster and do port scanning or make DDOS attacks.
更新
对于 ES 1.6+ 版
For ES Version 1.6+
可以通过需要添加到每个节点上的 config/elasticsearch.yml 文件中的以下设置,为每个脚本引擎启用基于源的脚本.
It is possible to enable scripts based on their source, for every script engine, through the following settings that need to be added to the config/elasticsearch.yml file on every node.
script.inline: on
script.indexed: on
这篇关于Elasticsearch 动态脚本已禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!