Authored by 胡古飞

Merge branch 'zf_agg' into gray

# Conflicts:
#	service/src/main/java/com/yoho/search/consumer/service/base/ProductIndexService.java
#	service/src/main/java/com/yoho/search/consumer/service/bo/ProductIndexBO.java
... ... @@ -526,13 +526,19 @@
"type": "string",
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex"
"search_analyzer": "ik_complex",
"copy_to": [
"searchField_ansj"
]
},
"pattern": {
"type": "string",
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex"
"search_analyzer": "ik_complex",
"copy_to": [
"searchField_ansj"
]
},
"isSpecial": {
"type": "string",
... ... @@ -772,7 +778,9 @@
"standardOnlyNames": {
"type": "string",
"index": "not_analyzed",
"copy_to": "searchField_ansj"
"copy_to": [
"searchField_ansj"
]
},
"standardOnlyNames_ansj": {
"type": "string",
... ... @@ -844,6 +852,11 @@
"analyzer": "lowercase_keyword_ngram",
"search_analyzer": "ik_complex"
},
"productAttrField": {
"type": "string",
"analyzer": "comma_spliter",
"search_analyzer": "ik_complex"
},
"isGlobal": {
"type": "string",
"index": "not_analyzed",
... ... @@ -961,7 +974,10 @@
"type": "string",
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex"
"search_analyzer": "ik_complex",
"copy_to": [
"searchField_ansj"
]
},
"sknDefaultImg": {
"type": "string",
... ...
... ... @@ -198,6 +198,7 @@ public class ProductIndexService {
map.put("attributeNames", productIndexBO.getAttributeNames());
map.put("shopName", productIndexBO.getShopName());
map.put("shopDomain", productIndexBO.getShopDomain());
map.put("productAttrField", productIndexBO.getProductAttrField());
return map;
}
... ...
... ... @@ -103,14 +103,16 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
// from `erp_product`.`product_ext`
private String sknDefaultImg;
//from erp_product.product_attribute yh_shops.product_attribute_property_values
// from erp_product.product_attribute
// yh_shops.product_attribute_property_values
private String attributeNames;
//from shops
private String shopName;
private String shopDomain;
// from shops
private String shopName;
private String shopDomain;
private String productAttrField;
// get
public BigDecimal getSpecialPrice() {
... ... @@ -140,7 +142,7 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
public BigDecimal getVip3Price() {
return vip3Price;
}
public String getVipLevels() {
return vipLevels;
}
... ... @@ -498,19 +500,27 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.attributeNames = attributeNames;
}
public String getShopName() {
return shopName;
}
public String getShopName() {
return shopName;
}
public void setShopName(String shopName) {
this.shopName = shopName;
}
public String getShopDomain() {
return shopDomain;
}
public void setShopName(String shopName) {
this.shopName = shopName;
}
public void setShopDomain(String shopDomain) {
this.shopDomain = shopDomain;
}
public String getShopDomain() {
return shopDomain;
}
public String getProductAttrField() {
return productAttrField;
}
public void setShopDomain(String shopDomain) {
this.shopDomain = shopDomain;
}
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("\\/", ",");
}
}
... ...