feat(core): 添加排序模式功能

- 在 OrderByParam 类中添加 sortMode 字段
- 在 WrapperProcessor 类中实现排序模式的设置
This commit is contained in:
阿杰 2025-08-18 11:18:25 +08:00
parent 569cd76d99
commit 78fe61fd1f
2 changed files with 9 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package org.dromara.easyes.core.biz;
import co.elastic.clients.elasticsearch._types.SortMode;
import lombok.Data;
/**
@ -17,4 +18,8 @@ public class OrderByParam {
* 排序规则 ASC:升序 DESC:降序
*/
private String sort;
/**
* 排序模式
*/
private SortMode mode;
}

View File

@ -644,6 +644,10 @@ public class WrapperProcessor {
if (SortOrder.Desc.toString().equalsIgnoreCase(orderByParam.getSort())) {
fieldSortBuilder.order(SortOrder.Desc);
}
// 设置排序模式
if (Objects.nonNull(orderByParam.getMode())) {
fieldSortBuilder.mode(orderByParam.getMode());
}
searchBuilder.sort(x -> x.field(fieldSortBuilder.build()));
});
}