elasticsearch 查询排序 调用 SearchSourceBuilder.sort方法 sort(String name, SortOrder order)
name:字段名
SortOrder:SortOrder.DESC 倒序,SortOrder.ASC 正序
代码如下:
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
SortBuilder sortBuilder = SortBuilders.fieldSort("sn").order(SortOrder.DESC);
searchSourceBuilder.sort("createDate", SortOrder.DESC );