修改es按照发布时间倒叙排序,发布时间为空放最后
This commit is contained in:
@@ -24,16 +24,15 @@ import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
|
||||
import org.dromara.easyes.core.conditions.update.LambdaEsUpdateWrapper;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.unit.DistanceUnit;
|
||||
import org.elasticsearch.search.sort.SortBuilders;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -573,7 +572,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
wrapper.and(x->x.le(ESJobDocument::getPostingDate, formattedEndDate));
|
||||
}
|
||||
if(Objects.nonNull(esJobSearch.getOrder())){
|
||||
wrapper.orderByDesc(ESJobDocument::getPostingDate);
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
if(esJobSearch.getOrder()==1){
|
||||
wrapper.orderByDesc(ESJobDocument::getIsHot);
|
||||
}
|
||||
@@ -582,7 +581,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
}
|
||||
}else{
|
||||
//默认按照发布时间倒叙
|
||||
wrapper.orderByDesc(ESJobDocument::getPostingDate);
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
}
|
||||
//企业用户排除es去除jobIds
|
||||
boolean isCompanyUser = StringUtil.IS_COMPANY_USER.equals(esJobSearch.getUserType());
|
||||
@@ -651,7 +650,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
wrapper.and(a->a.eq(ESJobDocument::getType,jobQuery.getType().trim()));
|
||||
}
|
||||
if(Objects.nonNull(jobQuery.getOrder())){
|
||||
wrapper.orderByDesc(ESJobDocument::getPostingDate);
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
if (jobQuery.getOrder()==1){
|
||||
wrapper.orderByDesc(ESJobDocument::getIsHot);
|
||||
wrapper.orderByDesc(ESJobDocument::getApplyNum);
|
||||
@@ -659,7 +658,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
}
|
||||
}else{
|
||||
//默认按照发布时间倒叙
|
||||
wrapper.orderByDesc(ESJobDocument::getPostingDate);
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
}
|
||||
EsPageInfo<ESJobDocument> esJobDocumentEsPageInfo = esJobDocumentMapper.pageQuery(wrapper, pageNum, pageSize);
|
||||
return esJobDocumentEsPageInfo;
|
||||
|
||||
Reference in New Issue
Block a user