Authored by 胡古飞

Merge branch 'gray' into 5.6-global

... ... @@ -352,7 +352,7 @@
"analyzer": "ik_complex",
"search_analyzer": "ik_complex"
},
"phrase": {
"phrase": {
"type": "string",
"index": "not_analyzed",
"doc_values": true,
... ... @@ -765,7 +765,7 @@
},
"standardNames": {
"type": "string",
"analyzer":"comma_spliter"
"analyzer": "comma_spliter"
},
"standardOnlyNames": {
"fields": {
... ... @@ -970,6 +970,31 @@
"forbiddenPageIds": {
"type": "string",
"analyzer": "comma_spliter"
},
"shopDomain": {
"type": "string",
"index": "not_analyzed"
},
"shopName": {
"fields": {
"shopName": {
"type": "string",
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"shopName_lowercase": {
"type": "string",
"store": false,
"analyzer": "lowercase_keyword",
"search_analyzer": "ik_complex"
}
},
"type": "multi_field"
}
}
}
... ...
... ... @@ -196,6 +196,8 @@ public class ProductIndexService {
map.put("isPhraseExist", productIndexBO.getIsPhraseExist());
map.put("pattern", productIndexBO.getPattern());
map.put("attributeNames", productIndexBO.getAttributeNames());
map.put("shopName", productIndexBO.getShopName());
map.put("shopDomain", productIndexBO.getShopDomain());
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,11 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
//from erp_product.product_attribute yh_shops.product_attribute_property_values
private String attributeNames;
//from shops
private String shopName;
private String shopDomain;
// get
public BigDecimal getSpecialPrice() {
return specialPrice;
... ... @@ -493,4 +498,19 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.attributeNames = attributeNames;
}
public String getShopName() {
return shopName;
}
public void setShopName(String shopName) {
this.shopName = shopName;
}
public String getShopDomain() {
return shopDomain;
}
public void setShopDomain(String shopDomain) {
this.shopDomain = shopDomain;
}
}
\ No newline at end of file
... ...
package com.yoho.search.consumer.service.logic.productIndex.viewBuilder;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.dal.ShopMapper;
import com.yoho.search.dal.model.Shops;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by wangnan on 2017/3/23.
*/
@Component
public class ShopBuilder implements ViewBuilder {
private final Logger logger = LoggerFactory.getLogger(ShopBuilder.class);
@Autowired
private ShopMapper shopMapper;
@Override
public void build(List<ProductIndexBO> productIndexBOs, List<Integer> ids, List<Integer> skns) {
List<Shops> shopsList = shopMapper.getPageLists(0, Integer.MAX_VALUE);
if (CollectionUtils.isEmpty(shopsList)) {
logger.warn("[class=GeneralDataBuilder][func=buildDataFromProductI] shopsList is empty");
return;
}
Map<Integer, Shops> shopMap = new HashMap<>();
shopsList.stream().collect(Collectors.toList()).forEach(shops -> shopMap.put(shops.getShopsId(), shops));
for (ProductIndexBO productIndexBO : productIndexBOs) {
Shops shops = shopMap.get(productIndexBO.getShopId());
if (shops != null) {
productIndexBO.setShopName(shops.getShopName());
productIndexBO.setShopDomain(shops.getShopDomain());
}
}
}
}
... ...