Skip to content

Commit

Permalink
fix: 优化es价格搜索,设置超出限制,则默认搜索最大值
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiGaoRobot committed Nov 29, 2022
1 parent 32ca2e4 commit ba6bb56
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import cn.hutool.core.util.ArrayUtil;
import cn.lili.cache.Cache;
import cn.lili.cache.CachePrefix;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
Expand Down Expand Up @@ -480,6 +481,15 @@ private void commonSearch(BoolQueryBuilder filterBuilder, EsGoodsSearchDTO searc
if (prices.length == 2) {
max = Convert.toDouble(prices[1], Double.MAX_VALUE);
}
if (min > max) {
throw new ServiceException("价格区间错误");
}
if (min > Double.MAX_VALUE) {
min = Double.MAX_VALUE;
}
if (max > Double.MAX_VALUE) {
max = Double.MAX_VALUE;
}
filterBuilder.must(QueryBuilders.rangeQuery("price").from(min).to(max).includeLower(true).includeUpper(true));
}
}
Expand Down

0 comments on commit ba6bb56

Please sign in to comment.