elasticsearch/elasticsearch — Issue #1382: Script sorting doesn't accept parameters
Author: clintongormley
Created: 2011-10-08 09:59:36+00:00
State: open

Hiya

There is a bug when providing params to a script sort. Depending on the position of the `params` parameter in the JSON, you get 2 different error messages:

curl -XPUT 'http://127.0.0.1:9200/foo/?pretty=1'
curl -XPOST 'http://127.0.0.1:9200/foo/bar?pretty=1' -d '
{
"text" : "foo"
}
'

## Parse Failure [_script sorting requires setting the script to sort by]]; }]

curl -XGET 'http://127.0.0.1:9200/foo/_search?pretty=1' -d '
{
"sort" : {
"_script" : {
"params" : {
"one" : 1
},
"script" : "one",
"type" : "number"
}
}
}
'

## PropertyAccessException[[Error: unresolvable property or identifier: one]

curl -XGET 'http://127.0.0.1:9200/foo/_search?pretty=1' -d '
{
"sort" : {
"_script" : {
"script" : "one",
"type" : "number",
"params" : {
"one" : 1
}
}
}
}
'