Hi,
I'm actually testing the ES 5.0 release candidate and i'm asking myself if it's still possible to sort results by scripting.
In the 5.0 doc Sort | Elasticsearch Guide [5.0] | Elastic its says it's possible but when i do that, i have
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "features that prevent cachability are disabled on this context"
}
]
Here is my test :
{"from": 0, "size":1,"sort": , "stored_fields": [ "_type","_id"], "query":{"bool":{ "must": [ { "match_all": {} } ], "filter": [ {"range": {"echeance_max": { "gte": "0" } } } ] } }, "aggs": { "par_types": { "terms": { "field": "_type" }, "aggs": { "les_plus_proches": { "top_hits": { "sort": [
{ "_script" : {"type" : "number", "script" : {
"lang": "painless",
"inline": "floor(abs((doc['altitude'].value)-search_altitude)/10)",
"params" : {
"search_altitude" : 200
}}, "order" : "asc"} }, {"_geo_distance": {"geoloc": {"lat": 39.9173 , "lon": 116.386 }, "order": "asc", "unit": "km" } } ], "size" : 1 } } } } } }
When i remove the script sorting it works :
{"from": 0, "size":1,"sort": , "stored_fields": [ "_type","_id"], "query":{"bool":{ "must": [ { "match_all": {} } ], "filter": [ {"range": {"echeance_max": { "gte": "0" } } } ] } }, "aggs": { "par_types": { "terms": { "field": "_type" }, "aggs": { "les_plus_proches": { "top_hits": { "sort": [
{"_geo_distance": {"geoloc": {"lat": 39.9173 , "lon": 116.386 }, "order": "asc", "unit": "km" } } ], "size" : 1 } } } } } }
Do i miss something ?
Thanks,
Alex