你去了:
"sort": { "_script": { "type": "number", "script": "return doc['price'].value-distance", "params": { "distance": 29 }, "lang": "groovy", "order": "desc" } }并且您需要启用动态脚本。
您也可以这样
"query": { "function_score": { "query": { "bool": { "should": [ { "match": { "description": "this is the text i want to find" } }, { "match": { "price": 29 } } ] } }, "functions": [ { "exp": { "price": { "origin": "29", "scale": "1", "decay": 0.999 } } } ] } }但这会改变
score自身。如果您想按距离(而不是其他)进行纯排序,那么我相信第一个选择是最好的。



