2016-05-17 42 views
1

我試圖運行下面的查詢:我卡在腳本查詢在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} 

我甚至已經改變了「 script.engine.groovy.inline.aggs「:在.yml文件中 請幫助:我關注此問題link

+1

呀,能夠在ES動態腳本:https://www.elastic.co/guide/en/elasticsearch/reference/電流/模塊-scripting.html#啓用動態腳本。啓用是用'true'和'false'並且重新啓動節點。 –

+2

該消息也是不言自明的:在啓用「groovy.inline.aggs」時,''inline],operation [search]和lang [groovy]的腳本被禁用。在發佈你的每一個小問題之前先閱讀一下。 –

+1

這個問題的答案在這裏:https://stackoverflow.com/questions/37345608/why-i-am-getting-error-while-executing-this-query-in-elasticsearch –

回答

2

您需要通過以下設置啓用腳本。走在你的elasticsearch文件夾 - > config-> elasticsearch.yml文件,加入:

script.inline: true 
script.indexed: true