...
|
...
|
@@ -18,6 +18,7 @@ import com.yoho.search.service.servicenew.ISknImageVectorsService; |
|
|
import com.yoho.search.service.utils.SearchApiResultUtils;
|
|
|
import com.yoho.search.service.vo.SearchApiResult;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.elasticsearch.common.lucene.search.function.CombineFunction;
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.index.query.MatchAllQueryBuilder;
|
...
|
...
|
@@ -26,6 +27,7 @@ import org.elasticsearch.index.query.QueryBuilders; |
|
|
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
|
|
|
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
|
|
|
import org.elasticsearch.index.query.functionscore.script.ScriptScoreFunctionBuilder;
|
|
|
import org.elasticsearch.script.Script;
|
|
|
import org.elasticsearch.script.ScriptService;
|
|
|
import org.elasticsearch.search.sort.SortBuilder;
|
|
|
import org.elasticsearch.search.sort.SortBuilders;
|
...
|
...
|
@@ -38,14 +40,7 @@ import org.springframework.context.ApplicationEventPublisherAware; |
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.elasticsearch.script.Script;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by wangnan on 2017/7/28.
|
...
|
...
|
@@ -103,7 +98,6 @@ public class SknImageVectorsServiceImpl implements ISknImageVectorsService, Appl |
|
|
if (pageSize > 50) {
|
|
|
pageSize = 50;
|
|
|
}
|
|
|
searchParam.setPage(page);
|
|
|
searchParam.setOffset((page - 1) * pageSize);
|
|
|
searchParam.setSize(VECTORS_32_QUERY_BACK_NUM);
|
|
|
searchParam.setQuery(buildFunctionScoreQueryBuilder(VECTORS_32_KEY, vectors_32, null));
|
...
|
...
|
@@ -120,11 +114,9 @@ public class SknImageVectorsServiceImpl implements ISknImageVectorsService, Appl |
|
|
sknFilterString += map.get("productSkn").toString() + ",";
|
|
|
}
|
|
|
//2.2第二次查询,用128维向量粗查询这些skn
|
|
|
searchParam.setPage(page);
|
|
|
searchParam.setOffset((page - 1) * pageSize);
|
|
|
searchParam.setSize(pageSize);
|
|
|
//todo 先用32维的,后面要改成128的
|
|
|
searchParam.setQuery(buildFunctionScoreQueryBuilder(VECTORS_32_KEY, vectors_32, sknFilterString));
|
|
|
searchParam.setQuery(buildFunctionScoreQueryBuilder(VECTORS_128_KEY, vectors_128, sknFilterString));
|
|
|
searchResult = searchCommonService.doSearch(indexName, searchParam);
|
|
|
if (CollectionUtils.isNotEmpty(searchResult.getResultList())) {
|
|
|
sknList = getSknImageMap(searchResult.getResultList());
|
...
|
...
|
|