弹性搜索动态脚本禁用 [英] Elasticsearch Dynamic Scripting Disabled

查看:116
本文介绍了弹性搜索动态脚本禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对汇总进行以下查询:

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:

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

推荐答案

默认情况下,弹性搜索中的动态脚本禁用,我们需要在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

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

此外,我们需要确保在启用动态脚本时,弹性搜索端口不是公开的。特别是节点用于通信的端口。 (默认为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 Version 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

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

这篇关于弹性搜索动态脚本禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆