Browse Source

物料构建搜索数据去掉pbranden不可为空限制

wangyc 6 years ago
parent
commit
2943aaccf6

+ 7 - 5
mall-search/src/main/java/com/uas/search/util/ObjectToDocumentUtils.java

@@ -101,8 +101,7 @@ public class ObjectToDocumentUtils {
 	 * @return
 	 */
 	public static Document toDocument(V_Products product) {
-		if (product == null || product.getId() == null || null == product.getEnUU() || StringUtils.isEmpty(product.getpBrandEn())
-				|| StringUtils.isEmpty(product.getpCmpCode())) {
+		if (product == null || product.getId() == null || null == product.getEnUU() || StringUtils.isEmpty(product.getpCmpCode())) {
 			return null;
 		}
 		Document document = new Document();
@@ -147,9 +146,12 @@ public class ObjectToDocumentUtils {
         if (!StringUtils.isEmpty(product.getSpec())) {
 			document.add(new TextField(SearchConstants.PRODUCT_PRIVATE_SPEC_FIELD, product.getSpec().toLowerCase(), Store.YES));
 		}
-
-        document.add(new StringField(SearchConstants.PRODUCT_PRIVATE_PBRANDEN_FIELD, product.getpBrandEn().toLowerCase(), Store.YES));
-		document.add(new StringField(SearchConstants.PRODUCT_PRIVATE_PCMPCODE_FIELD, product.getpCmpCode().toLowerCase(), Store.YES));
+		if (!StringUtils.isEmpty(product.getpBrandEn())) {
+			document.add(new StringField(SearchConstants.PRODUCT_PRIVATE_PBRANDEN_FIELD, product.getpBrandEn().toLowerCase(), Store.YES));
+		}
+        if (!StringUtils.isEmpty(product.getpCmpCode())) {
+			document.add(new StringField(SearchConstants.PRODUCT_PRIVATE_PCMPCODE_FIELD, product.getpCmpCode().toLowerCase(), Store.YES));
+		}
 		if (product.getStandard() != null) {
 			document.add(new StringField(SearchConstants.PRODUCT_PRIVATE_STANDARD_FIELD, String.valueOf(product.getStandard()), Store.YES));
 		} else {