...
|
...
|
@@ -283,7 +283,8 @@ public class SortRecallSceneService extends AbstractRecallService { |
|
|
String vectorFeatureVersion = searchDynamicConfigService.personalizedSearchVersion();
|
|
|
String userVectorFeature = bigDataRedisService.getUserBrandVectorFeature(uid, vectorFeatureVersion);
|
|
|
if (StringUtils.isBlank(vectorFeatureVersion) || StringUtils.isBlank(userVectorFeature)) {
|
|
|
return new ArrayList<Integer>();
|
|
|
vectorFeatureVersion = "1";
|
|
|
userVectorFeature = "2";
|
|
|
}
|
|
|
SearchParam searchParam = new SearchParam();
|
|
|
// 1、设置filter
|
...
|
...
|
@@ -311,15 +312,15 @@ public class SortRecallSceneService extends AbstractRecallService { |
|
|
scriptParams.put("field", "brandFeature");
|
|
|
scriptParams.put("userFeatureFactors", userVectorFeature);
|
|
|
scriptParams.put("vectorFeatureVersion", vectorFeatureVersion);
|
|
|
scriptParams.put("baseConstant", "1.0");
|
|
|
scriptParams.put("factorConstant", "1.0");
|
|
|
scriptParams.put("baseConstant", 1.0d);
|
|
|
scriptParams.put("factorConstant", 1.0d);
|
|
|
Script script = new Script(ScriptType.INLINE, "native", "feature_factor_vector_score", scriptParams);
|
|
|
FunctionScoreQueryBuilder functionScoreQueryBuilder = new FunctionScoreQueryBuilder(ScoreFunctionBuilders.scriptFunction(script));
|
|
|
searchParam.setQuery(functionScoreQueryBuilder);
|
|
|
// 3、设置order
|
|
|
searchParam.setSortBuilders(Arrays.asList(SortBuilders.scoreSort().order(SortOrder.DESC)));
|
|
|
searchParam.setOffset(0);
|
|
|
searchParam.setSize(10);
|
|
|
searchParam.setSize(20);
|
|
|
|
|
|
// 4、查询es
|
|
|
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_BRAND, searchParam);
|
...
|
...
|
|