ElesticSearchTemplate多字段排序

以前我们可以这样写:

 
 
Order order1 = new Order(Sort.Direction.ASC, "field1");
Order order2 = new Order(Sort.Direction.DESC, "field2");
Sort sort = new Sort(order1, order2);

但是现在会出现:

Sort sort = new Sort(order1, order2);

这种方法已过时,那肯定是不推荐使用了。

可以采用以下方式:

Sort sort = new Sort(Sort.Direction.ASC,"field1").and(new Sort(Sort.Direction.DESC, "field2"));

代码手打,有错误请自行更改。

猜你喜欢

转载自blog.csdn.net/qq_34972627/article/details/80282436