格式应为
s=Search() s = s.sort({"time":{"order":"asc"}}, {"anoter_field":{"order":"desc"}}) s.execute()
问题是我想把 {"time":{"order":"asc"}}, {"anoter_field":{"order":"desc"}}
{"time":{"order":"asc"}}, {"anoter_field":{"order":"desc"}}
我的输入是一个dict,看起来像
input = {"time":"asc", "another_field":"desc"}
data_input = {"time":"asc", "another_field":"desc"} args = [{k:{'order':v}} for k,v in data_input.items()] s.sort(*args)
我猜这就是你要问的?很难说。。。