elasticsearch默認查詢時按照文檔添加前後進行排序elasticsearch
GET telegraph/_search { "query": { "match_all": {} } }
GET telegraph/_search { "query": { "match": { "title": "召開會議" } } }
按照發布時間倒序排序測試
GET telegraph/_search { "query": { "match_all": {} }, "sort": [ { "pubdate": { "order": "desc" } } ] }
建立索引,添加測試數據spa
DELETE my_person PUT my_person PUT my_person/my_index/1 { "name":"sean", "age":22, "salary":6000 } PUT my_person/my_index/2 { "name":"sim", "age":20, "salary":5000 } PUT my_person/my_index/3 { "name":"duck", "age":28, "salary":8000 } PUT my_person/my_index/4 { "name":"lily", "age":20, "salary":4000 }
按照」age「倒序排序,當」age「相同時按照」salary「升序排序code
GET my_person/_search { "sort": [ { "age": { "order": "desc" } }, { "salary": { "order": "asc" } } ] }