es分页,pageNum从0开始和es排序代码demo
如果从1开始,每页150条记录,可能查询不到结果。排查下来是初始的第一页的参数错误。
参数从0开始计算,es搜素,需要注意起始页。否则查询结果为空。
//es分页,pageNum从0开始。 protected void page(OrderVO reqVO, SearchSourceBuilder searchSourceBuilder) { searchSourceBuilder.from((reqVO.getPageNum()) * reqVO.getPageSize()).size(reqVO.getPageSize()); } //es排序,以下单请求时间倒序 protected void sort(OrderVO reqVO, SearchSourceBuilder searchSourceBuilder) { searchSourceBuilder.sort(SortBuilders.fieldSort("order.reqTime").order(SortOrder.DESC)); } //请求的参数demo,第一页,每页150条记录 {"pageSize":150,"pageNum":0,"memNo":849363394,"flag":"1"}
标签:reqVO,pageNum,searchSourceBuilder,demo,排序,es From: https://www.cnblogs.com/oktokeep/p/18559035