你去了:
"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自身。如果您想按距离(而不是其他)进行纯排序,那么我相信第一个选择是最好的。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)