```
"sort" : {
"_script" : {
"type" : "number",
"script" : {
"lang": "painless",
"source": "doc['photoId'].value * params.factor",
"params" : {
"factor" : 1.1
}
},
"order" : "asc"
}
}
···
这是我查询里的排序脚本,报400.
```
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[_script] failed to parse field [script]",
"line": 35,
"col": 17
}
],
"type": "parsing_exception",
"reason": "[_script] failed to parse field [script]",
"line": 35,
"col": 17,
"caused_by": {
"type": "illegal_argument_exception",
"reason": "[script] unknown field [source], parser not found"
}
},
"status": 400
}
```
但是官方文档也这么写的啊
不能粘图片就把官网的code粘过来了
```
GET /_search { "query" : { "term" : { "user" : "kimchy" } }, "sort" : { "_script" : { "type" : "number", "script" : { "lang": "painless", "source": "doc['field_name'].value * params.factor", "params" : { "factor" : 1.1 } }, "order" : "asc" } } }
```
"sort" : {
"_script" : {
"type" : "number",
"script" : {
"lang": "painless",
"source": "doc['photoId'].value * params.factor",
"params" : {
"factor" : 1.1
}
},
"order" : "asc"
}
}
···
这是我查询里的排序脚本,报400.
```
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[_script] failed to parse field [script]",
"line": 35,
"col": 17
}
],
"type": "parsing_exception",
"reason": "[_script] failed to parse field [script]",
"line": 35,
"col": 17,
"caused_by": {
"type": "illegal_argument_exception",
"reason": "[script] unknown field [source], parser not found"
}
},
"status": 400
}
```
但是官方文档也这么写的啊
不能粘图片就把官网的code粘过来了
```
GET /_search { "query" : { "term" : { "user" : "kimchy" } }, "sort" : { "_script" : { "type" : "number", "script" : { "lang": "painless", "source": "doc['field_name'].value * params.factor", "params" : { "factor" : 1.1 } }, "order" : "asc" } } }
```
1 个回复
rochy - rochy_he
赞同来自:
如果你使用的是 ES2.X,那么是不支持这种写法的