我在Elasticsearch中遇到了Script查询

时间:2016-05-17 10:59:10

标签: elasticsearch

我正在尝试运行以下查询:

curl -XGET localhost:9200/new_population/_search -d '{

"query":{
"bool" : {
    "must" : {
       "term":{"message":"developer"}
    },
    "filter" : {
        "script" : {
            "script" : "doc['birth'].value > 20"
        }
    }
}
}
}'

但我收到以下错误:

 {"error":{"root_cause":[{"type":"script_exception","reason":"scripts of type [inline], operation [search] and lang [groovy] are disabled"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"new_population","node":"AEKkYpmhRuWEOTJo64WKhg","reason":{"type":"script_exception","reason":"scripts of type [inline], operation [search] and lang [groovy] are disabled"}}]},"status":500}

我甚至在.yml文件中更改了“script.engine.groovy.inline.aggs”: 请帮忙:我正在关注此link

1 个答案:

答案 0 :(得分:2)

您需要通过以下设置启用脚本。进入elasticsearch文件夹 - > config-> elasticsearch.yml文件并添加:

script.inline: true
script.indexed: true