在弹性搜索查询中使用groovy脚本*文件* - groovy脚本文件位置 [英] Using a groovy script *file* in an elasticsearch query - groovy script file location
问题描述
我试图引用我创建的groovy脚本文件,找不到(见下文)。我没有一个config目录,而elasticsearch.yml在etc / elasticsearch中。我在usr / share / elasticsearch下添加了config / scripts /,所以我现在有/ usr / share / elasticsearch / config / scripts /.
I'm trying to reference a groovy script file that I created, and getting unable to find (see below). I didn't have a config directory, and elasticsearch.yml is in etc/elasticsearch. I added config/scripts/ under usr/share/elasticsearch so I now have /usr/share/elasticsearch/config/scripts/.
- 'source_types.groovy',我运行chown弹性搜索:弹性搜索,以确保用户称为elasticsearch拥有它。
In there, I placed my script- 'source_types.groovy', which I ran chown elasticsearch:elasticsearch on to ensure the user called elasticsearch owns it.
我也把一个config / scripts / source_types.groovy放在etc / elasticsearch中。
I also put a config/scripts/source_types.groovy in etc/elasticsearch.
调用脚本如下:
GET nr-01/_search
{
"query": {
"filtered": {
"filter": {
"script": {
"file": "source_types.groovy",
"lang": "groovy"
}
}
}
}
}
我正在获得
nested: SearchParseException[[nr-01][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n \"query\": {\n \"filtered\": {\n \"filter\": {\n \"script\": {\n \"file\": \"source_types.groovy\",\n \"lang\": \"groovy\"\n }\n }\n }\n }\n}\n]]]; nested: ElasticsearchIllegalArgumentException[Unable to find on disk script source_types.groovy]; }]",
"status": 400
显然无法找到该文件脚本去哪里?我正在调用它吗?
Obviously the file can't be found. Where does the script go? Am I calling it correctly?
推荐答案
把你的 *。groovy
文件在 / etc / elasticsearch / scripts
文件夹(意思是省略 config
)
Put your *.groovy
files under /etc/elasticsearch/scripts
folder (meaning omitting config
).
这篇关于在弹性搜索查询中使用groovy脚本*文件* - groovy脚本文件位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!