ElasticSearch [脚本] 未知字段 [文件],未找到解析器
ElasticSearch [script] unknown field [file], parser not found
我用script_score
自定义评分:
GET /customer/_search
{
"query": {
"function_score": {
"query": {
"match": {
"name": "Mark"
}
},
"script_score": {
"script": {
"lang": "painless",
"file": "test"
}
}
}
}
}
我设置了 "file": "test"
,并将 test.groovy
文件放在 config/scripts
目录中,但是我得到了这些错误:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "[script] unknown field [file], parser not found"
}
],
"type": "illegal_argument_exception",
"reason": "[script] unknown field [file], parser not found"
},
"status": 400
}
[script] unknown field [file], parser not found
!为什么?我需要安装一些插件吗?
Elasticsearch 版本:6.2.3
已安装插件:None
JVM 版本:1.8.0_181
OS 版本: Ubuntu Linux 4.4.0-124-generic
File scripts have been removed in ES 6.0, you should now use stored scripts 代替。
您可以轻松migrate your Groovy script to Painless。
首先,存储您的脚本:
POST _scripts/test
{
"script": {
"lang": "painless",
"source": "Math.log(_score * 2)"
}
}
然后在您的查询中使用它:
GET /customer/_search
{
"query": {
"function_score": {
"query": {
"match": {
"name": "Mark"
}
},
"script_score": {
"script": {
"id": "test"
}
}
}
}
}
我用script_score
自定义评分:
GET /customer/_search
{
"query": {
"function_score": {
"query": {
"match": {
"name": "Mark"
}
},
"script_score": {
"script": {
"lang": "painless",
"file": "test"
}
}
}
}
}
我设置了 "file": "test"
,并将 test.groovy
文件放在 config/scripts
目录中,但是我得到了这些错误:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "[script] unknown field [file], parser not found"
}
],
"type": "illegal_argument_exception",
"reason": "[script] unknown field [file], parser not found"
},
"status": 400
}
[script] unknown field [file], parser not found
!为什么?我需要安装一些插件吗?
Elasticsearch 版本:6.2.3
已安装插件:None
JVM 版本:1.8.0_181
OS 版本: Ubuntu Linux 4.4.0-124-generic
File scripts have been removed in ES 6.0, you should now use stored scripts 代替。
您可以轻松migrate your Groovy script to Painless。
首先,存储您的脚本:
POST _scripts/test
{
"script": {
"lang": "painless",
"source": "Math.log(_score * 2)"
}
}
然后在您的查询中使用它:
GET /customer/_search
{
"query": {
"function_score": {
"query": {
"match": {
"name": "Mark"
}
},
"script_score": {
"script": {
"id": "test"
}
}
}
}
}