Sorting by multiple params in pyes and elasticsearch
If you'd like the results in the result set with the same score to be ordered by price, append price to the sort string:
s = MatchAllQuery()conn.search(query=Search(s), indexes=["test"], sort='_score,price')
By default the sort order is ascending. To pass the sort order append :asc or :desc to the sort parameter
s = MatchAllQuery()conn.search(query=Search(s), indexes=["test"], sort='_score,price:desc')
If you want to do more detailed sorting that what's available via es.search
's sort
keyword, you can just pass the search dict into the es.Search
constructor.
s = Search({'term': {'foo.monkey': 'george'}}, sort=[{'_geo_distance': {'unit': 'mi', 'order': 'desc', 'monkey.location': '81,20'}}]) conn.search(s)