Authored by unknown

fix page

package com.yoho.search.service.servicenew.impl;
import com.alibaba.fastjson.JSONObject;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.service.cache.SearchCacheFactory;
import com.yoho.search.service.cache.model.SearchCache;
import com.yoho.search.service.service.SearchCacheService;
import com.yoho.search.service.service.SearchCommonService;
import com.yoho.search.service.service.base.ProductIndexBaseService;
import com.yoho.search.service.servicenew.ISknImageVectorsService;
import com.yoho.search.service.utils.SearchApiResultUtils;
import com.yoho.search.service.vo.SearchApiResult;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.common.lucene.search.function.CombineFunction;
... ... @@ -38,8 +30,22 @@ import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.*;
import com.alibaba.fastjson.JSONObject;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.service.cache.SearchCacheFactory;
import com.yoho.search.service.cache.model.SearchCache;
import com.yoho.search.service.service.SearchCacheService;
import com.yoho.search.service.service.SearchCommonService;
import com.yoho.search.service.service.base.ProductIndexBaseService;
import com.yoho.search.service.servicenew.ISknImageVectorsService;
import com.yoho.search.service.utils.SearchApiResultUtils;
import com.yoho.search.service.vo.SearchApiResult;
/**
* Created by wangnan on 2017/7/28.
... ... @@ -102,7 +108,6 @@ public class SknImageVectorsServiceImpl implements ISknImageVectorsService, Appl
if (pageSize > 50) {
pageSize = 50;
}
searchParam.setPage(page);
searchParam.setOffset((page - 1) * pageSize);
searchParam.setSize(pageSize);
searchParam.setQuery(buildFunctionScoreQueryBuilder(vectorsFieldName,vectorsValue));
... ... @@ -135,7 +140,6 @@ public class SknImageVectorsServiceImpl implements ISknImageVectorsService, Appl
searchParam.setFiter(this.getDefaultBoolQueryBuilder());
searchParam.setQuery(this.builderProductQueryBuilder(paramMap, querySknList));
searchParam.setAggregationBuilders(null);
searchParam.setPage(page);
searchParam.setOffset((page - 1) * pageSize);
searchParam.setSize(pageSize);
List<SortBuilder> sortBuilders = new ArrayList<>();
... ... @@ -162,7 +166,7 @@ public class SknImageVectorsServiceImpl implements ISknImageVectorsService, Appl
dataMap.put("page", searchResult.getPage());
dataMap.put("page_size", searchParam.getSize());
dataMap.put("page_total", searchResult.getTotalPage());
dataMap.put("product_list", productIndexBaseService.getProductListWithPricePlan(searchResult.getResultList(), Arrays.asList("phrase")));
dataMap.put("product_list", productIndexBaseService.getProductListWithPricePlan(searchResult.getResultList()));
photoListData.put("photoListData", dataMap);
// 5.将结果存进缓存
searchCacheService.addJSONObjectToCache(searchCache, indexName, searchParam, photoListData);
... ...