mirror of
https://gitee.com/dromara/easy-es.git
synced 2025-12-07 17:48:42 +08:00
feat(core): 添加排序模式功能
- 在 OrderByParam 类中添加 sortMode 字段 - 在 WrapperProcessor 类中实现排序模式的设置
This commit is contained in:
parent
569cd76d99
commit
78fe61fd1f
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.easyes.core.biz;
|
package org.dromara.easyes.core.biz;
|
||||||
|
|
||||||
|
import co.elastic.clients.elasticsearch._types.SortMode;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,4 +18,8 @@ public class OrderByParam {
|
|||||||
* 排序规则 ASC:升序 DESC:降序
|
* 排序规则 ASC:升序 DESC:降序
|
||||||
*/
|
*/
|
||||||
private String sort;
|
private String sort;
|
||||||
|
/**
|
||||||
|
* 排序模式
|
||||||
|
*/
|
||||||
|
private SortMode mode;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -644,6 +644,10 @@ public class WrapperProcessor {
|
|||||||
if (SortOrder.Desc.toString().equalsIgnoreCase(orderByParam.getSort())) {
|
if (SortOrder.Desc.toString().equalsIgnoreCase(orderByParam.getSort())) {
|
||||||
fieldSortBuilder.order(SortOrder.Desc);
|
fieldSortBuilder.order(SortOrder.Desc);
|
||||||
}
|
}
|
||||||
|
// 设置排序模式
|
||||||
|
if (Objects.nonNull(orderByParam.getMode())) {
|
||||||
|
fieldSortBuilder.mode(orderByParam.getMode());
|
||||||
|
}
|
||||||
searchBuilder.sort(x -> x.field(fieldSortBuilder.build()));
|
searchBuilder.sort(x -> x.field(fieldSortBuilder.build()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user