Authored by 胡古飞

fix bug

... ... @@ -65,20 +65,20 @@ public class PersonalVectorFeatureSearch {
}
public void addPersonalizedScriptScoreUserProductFeature(FunctionScoreQueryBuilder functionScoreQueryBuilder, String productVectorFeature) {
// 1. 获取特征向量版本(即生成时间,该时间需要与skn的生成时间一致才有意义)
String vectorFeatureVersion = searchDynamicConfigService.personalizedSearchVersion();
if (StringUtils.isEmpty(vectorFeatureVersion) || "-1".equals(vectorFeatureVersion)) {
return;
}
// 2. 获取商品特征向量
// 1. 获取商品特征向量
if(StringUtils.isBlank(productVectorFeature)){
return;
}
// 3. 传入参数调用脚本,以商品特征代替用户特征
// 2. 传入参数调用脚本,以商品特征代替用户特征
Map<String, Object> scriptParams = new HashMap<>();
scriptParams.put("field", "productFeatureFactor");
scriptParams.put("userFeatureFactors", productVectorFeature);
scriptParams.put("vectorFeatureVersion", vectorFeatureVersion);
String [] productVectorFeatures = productVectorFeature.split("|",2);
if(productVectorFeatures!=2){
return;
}
scriptParams.put("userFeatureFactors", productVectorFeatures[1]);
scriptParams.put("vectorFeatureVersion", productVectorFeatures[0]);
scriptParams.put("baseConstant", BASE_CONSTANT);
scriptParams.put("factorConstant", FACTOR_CONSTANT);
Script script = new Script("feature_factor_vector_score", ScriptService.ScriptType.INLINE, "native", scriptParams);
... ...