Authored by hugufei

添加heatValue和salesPrice

package com.yoho.search.consumer.index.fullbuild;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -34,12 +36,13 @@ public class ProductBaseIndexBuilder extends IIndexBuilder {
}
return dataList;
}
private Map<String, Object> getProductBaseMap(Product product) {
Map<String, Object> productMap = new HashMap<String, Object>();
productMap.put("id", product.getId());
productMap.put("productSkn", product.getErpProductId());
productMap.put("productName", product.getProductName());
productMap.put("status", product.getStatus());
productMap.put("shopId", product.getShopId());
productMap.put("brandId", product.getBrandId());
productMap.put("maxSortId", product.getMaxSortId());
... ... @@ -47,12 +50,28 @@ public class ProductBaseIndexBuilder extends IIndexBuilder {
productMap.put("smallSortId", product.getSmallSortId());
productMap.put("phrase", product.getPhrase());
productMap.put("firstShelveTime", product.getFirstShelveTime());
productMap.put("heatValue",getHeatValue());
productMap.put("salesPrice",getSalesPrice());
return productMap;
}
@Override
public String getId(Object object) {
return ((Map<?, ?>) object).get("id").toString();
}
private static double getHeatValue() {
DecimalFormat df = new DecimalFormat("######0.0");
return Double.valueOf(df.format((double) (10 * Math.random())));
}
private static double getSalesPrice() {
DecimalFormat df = new DecimalFormat("######0.00");
return Double.valueOf(df.format((double) (100000 * Math.random())));
}
public static void main(String[] args) {
System.out.println(getHeatValue());
System.out.println(getSalesPrice());
}
}
... ...
... ... @@ -17,6 +17,9 @@
"type": "text",
"analyzer": "standard"
},
"status": {
"type": "integer"
},
"shopId": {
"type": "integer"
},
... ... @@ -32,12 +35,18 @@
"middleSortId": {
"type": "integer"
},
"phrase": {
"type": "text",
"index": "no"
},
"firstShelveTime": {
"type": "integer"
},
"phrase": {
"type": "text",
"index": "no"
"heatValue": {
"type": "double"
},
"salesPrice": {
"type": "double"
}
}
}
... ...