|
|
@@ -1161,20 +1161,22 @@ public class SearchServiceImpl implements SearchService {
|
|
|
|
|
|
productsFields.add(SearchConstants.PRODUCT_PRIVATE_CMPCODE_FIELD);
|
|
|
productsFields.add(SearchConstants.PRODUCT_PRIVATE_PCMPCODE_FIELD);
|
|
|
-
|
|
|
+ PageParams stockPageParams = new PageParams(pageParams);
|
|
|
+ PageParams futuresPageParams = new PageParams(pageParams);
|
|
|
// 现货
|
|
|
- Map<String, Object> stock = getGoodsIds(keyword, goodsFields, true, pageParams);
|
|
|
+ Map<String, Object> stock = getGoodsIds(keyword, goodsFields, false, pageParams);
|
|
|
// 如搜索无结果则分词
|
|
|
if (CollectionUtils.isEmpty(stock) || stock.get("content") == null || JSONObject.parseArray(stock.get("content").toString()).isEmpty()) {
|
|
|
keyword = recursivelyGetGoodsIds(keyword, null, true);
|
|
|
- stock = getGoodsIds(keyword, goodsFields, true, pageParams);
|
|
|
+ stock = getGoodsIds(keyword, goodsFields, true, stockPageParams);
|
|
|
}
|
|
|
// 期货
|
|
|
- SPage<Long> futures = getProductIds(keyword, productsFields, true, pageParams);
|
|
|
+ PageParams recursivelyPageParams = new PageParams(pageParams);
|
|
|
+ SPage<Long> futures = getProductIds(keyword, productsFields, false, futuresPageParams);
|
|
|
// 如搜索无结果则分词
|
|
|
if (futures == null || CollectionUtils.isEmpty(futures.getContent())) {
|
|
|
keyword = recursivelyProductIds(keyword, productsFields, true);
|
|
|
- futures = getProductIds(keyword, productsFields, true, pageParams);
|
|
|
+ futures = getProductIds(keyword, productsFields, true, recursivelyPageParams);
|
|
|
}
|
|
|
map.put("stock", stock);
|
|
|
map.put("futures", futures);
|
|
|
@@ -1296,6 +1298,9 @@ public class SearchServiceImpl implements SearchService {
|
|
|
if (pageParams.getPage() > 1) {// 不是第一页
|
|
|
TopDocs previousHits = indexSearcher.search(booleanQuery, (pageParams.getPage() - 1) * pageParams.getSize(), sort, true, false);
|
|
|
int totalHits = previousHits.totalHits;
|
|
|
+ if (totalHits == 0) {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
int totalPage = (int) Math.ceil(totalHits / (1.0 * pageParams.getSize()));
|
|
|
if (pageParams.getPage() > totalPage) {
|
|
|
pageParams.setPage(totalPage);
|