Authored by Gino Zhang

品类页/模糊搜索页增加推荐词的功能 增加一个productAttrField字段去聚合

... ... @@ -528,8 +528,7 @@
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": [
"searchField_ansj",
"productAttrField"
"searchField_ansj"
]
},
"pattern": {
... ... @@ -538,8 +537,7 @@
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": [
"searchField_ansj",
"productAttrField"
"searchField_ansj"
]
},
"isSpecial": {
... ... @@ -781,8 +779,7 @@
"type": "string",
"index": "not_analyzed",
"copy_to": [
"searchField_ansj",
"productAttrField"
"searchField_ansj"
]
},
"standardOnlyNames_ansj": {
... ... @@ -982,8 +979,7 @@
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": [
"searchField_ansj",
"productAttrField"
"searchField_ansj"
]
},
"sknDefaultImg": {
... ...
... ... @@ -196,6 +196,7 @@ public class ProductIndexService {
map.put("isPhraseExist", productIndexBO.getIsPhraseExist());
map.put("pattern", productIndexBO.getPattern());
map.put("attributeNames", productIndexBO.getAttributeNames());
map.put("productAttrField", productIndexBO.getProductAttrField());
return map;
}
... ...
package com.yoho.search.consumer.service.bo;
import com.alibaba.fastjson.JSONArray;
import java.io.Serializable;
import java.math.BigDecimal;
import com.alibaba.fastjson.JSONArray;
/**
* 商品实体索引
*
... ... @@ -107,6 +107,8 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
//from erp_product.product_attribute yh_shops.product_attribute_property_values
private String attributeNames;
private String productAttrField;
// get
public BigDecimal getSpecialPrice() {
return specialPrice;
... ... @@ -493,4 +495,11 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.attributeNames = attributeNames;
}
public String getProductAttrField() {
return productAttrField;
}
public void setProductAttrField(String productAttrField) {
this.productAttrField = productAttrField;
}
}
\ No newline at end of file
... ...
... ... @@ -12,6 +12,7 @@ import com.yoho.search.dal.model.Brand;
import com.yoho.search.dal.model.Product;
import com.yoho.search.dal.model.ProductSort;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
... ... @@ -135,8 +136,41 @@ public class ProductIndexLogicService implements ApplicationContextAware {
viewBuilderList.stream().forEach(viewBuilder -> {
viewBuilder.build(productIndexBOs, ids, skns);
});
// 构造一个由风格、款式和属性拼接而成的关键词字段 用于关键词推荐
productIndexBOs.forEach(productIndexBO -> {
productIndexBO.setProductAttrField(contrustAttrField(productIndexBO));
});
return productIndexBOs;
}
private String contrustAttrField(ProductIndexBO productIndexBO) {
StringBuffer sb = new StringBuffer(100);
String value = productIndexBO.getStyle();
if(StringUtils.isNotEmpty(value)){
sb.append(value).append(',');
}
value = productIndexBO.getStandardOnlyNames();
if(StringUtils.isNotEmpty(value)){
sb.append(value).append(',');
}
value = productIndexBO.getAttributeNames();
if(StringUtils.isNotEmpty(value)){
sb.append(value).append(',');
}
value = productIndexBO.getPattern();
if(StringUtils.isNotEmpty(value)){
sb.append(value).append(',');
}
if(sb.length() == 0){
return null;
}
return sb.substring(0, sb.length() - 1).replaceAll("\\/", ",");
}
}
... ...