Authored by Gino Zhang

suggestConvert不处理排序关系 改由service来处理; suggest增加style名称

@@ -17,6 +17,7 @@ public enum KeywordType { @@ -17,6 +17,7 @@ public enum KeywordType {
17 ProductKeywordToken(5, 6,SuggestionConstants.PRODUCTKEYWORD_TOKEN_ENABLED_KEY), 17 ProductKeywordToken(5, 6,SuggestionConstants.PRODUCTKEYWORD_TOKEN_ENABLED_KEY),
18 BrandKeywordToken(6, 6, SuggestionConstants.BRANDKEYWORD_TOKEN_ENABLED_KEY), 18 BrandKeywordToken(6, 6, SuggestionConstants.BRANDKEYWORD_TOKEN_ENABLED_KEY),
19 19
  20 + StyleName(13, 4, SuggestionConstants.STYLENAME_ENABLED_KEY),
20 ParameterMake(12, 3, SuggestionConstants.PARAMETERMAKE_ENABLED_KEY), 21 ParameterMake(12, 3, SuggestionConstants.PARAMETERMAKE_ENABLED_KEY),
21 22
22 ProductName(8, 1, SuggestionConstants.PRODUCTNAME_ENABLED_KEY), 23 ProductName(8, 1, SuggestionConstants.PRODUCTNAME_ENABLED_KEY),
@@ -16,7 +16,7 @@ public class SuggestionConstants { @@ -16,7 +16,7 @@ public class SuggestionConstants {
16 16
17 public static final Integer VALID_STATUS = Integer.valueOf(1); 17 public static final Integer VALID_STATUS = Integer.valueOf(1);
18 18
19 - public static final List<String> IGNORE_KEYWORDS = Arrays.asList("其他","正常","中文","中国","普通","2%","时尚"); 19 + public static final List<String> IGNORE_KEYWORDS = Arrays.asList("其他","正常","中文","中国","普通","2%","时尚","标准","标准款","模型","其它");
20 20
21 /** 21 /**
22 * 返回智能搜索词的数量 22 * 返回智能搜索词的数量
@@ -38,6 +38,7 @@ public class SuggestionConstants { @@ -38,6 +38,7 @@ public class SuggestionConstants {
38 public static String SHOPNAME_ENABLED_KEY = "search.suggestion.consumer.shopname.enable"; 38 public static String SHOPNAME_ENABLED_KEY = "search.suggestion.consumer.shopname.enable";
39 public static String PRODUCTNAME_ENABLED_KEY = "search.suggestion.consumer.productname.enable"; 39 public static String PRODUCTNAME_ENABLED_KEY = "search.suggestion.consumer.productname.enable";
40 public static String PARAMETERMAKE_ENABLED_KEY = "search.suggestion.consumer.parametermake.enable"; 40 public static String PARAMETERMAKE_ENABLED_KEY = "search.suggestion.consumer.parametermake.enable";
  41 + public static String STYLENAME_ENABLED_KEY = "search.suggestion.consumer.stylename.enable";
41 42
42 public static int FETCH_HOTKEYWORD_COUNT = 10000; 43 public static int FETCH_HOTKEYWORD_COUNT = 10000;
43 44
  1 +package com.yoho.search.consumer.suggests.discover;
  2 +
  3 +import com.yoho.search.consumer.service.base.StyleService;
  4 +import com.yoho.search.consumer.suggests.common.KeywordType;
  5 +import com.yoho.search.consumer.suggests.common.SuggestionConstants;
  6 +import com.yoho.search.dal.model.Style;
  7 +import org.apache.commons.collections.CollectionUtils;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +import java.util.HashSet;
  12 +import java.util.List;
  13 +import java.util.Set;
  14 +
  15 +/**
  16 + * Created by ginozhang on 2016/11/25.
  17 + */
  18 +@Component
  19 +public class StyleNameSuggestionDiscoverer extends AbstractSuggestionDiscoverer {
  20 +
  21 + @Autowired
  22 + private StyleService styleService;
  23 +
  24 + @Override
  25 + public int count() {
  26 + return styleService.count();
  27 + }
  28 +
  29 + @Override
  30 + public Set<String> getSuggestWordSet(int pageNo, int batchSize) {
  31 + Set<String> styleNameSet = new HashSet<>(batchSize);
  32 + int start = (pageNo - 1) * batchSize;
  33 + List<Style> styleList = styleService.getStylePageLists(start, batchSize);
  34 + if (CollectionUtils.isNotEmpty(styleList)) {
  35 + for (Style style : styleList) {
  36 + if (style.getStyleName() != null && style.getStyleName().length() > 1) {
  37 + if (!SuggestionConstants.IGNORE_KEYWORDS.contains(style.getStyleName())) {
  38 + styleNameSet.add(style.getStyleName());
  39 + }
  40 + }
  41 + }
  42 + }
  43 +
  44 + return styleNameSet;
  45 + }
  46 +
  47 + @Override
  48 + public KeywordType getKeywordType() {
  49 + return KeywordType.StyleName;
  50 + }
  51 +
  52 +}
@@ -75,7 +75,6 @@ public class SuggestConvertorService { @@ -75,7 +75,6 @@ public class SuggestConvertorService {
75 75
76 public YohoKeywordsBO buildYohoKeywordBO() { 76 public YohoKeywordsBO buildYohoKeywordBO() {
77 Set<String> keywordSet = new HashSet<>(3000); 77 Set<String> keywordSet = new HashSet<>(3000);
78 - Set<String> filterSortNameSet = new HashSet<>(300);  
79 Set<String> sortNameSet = getSortNameSet(); 78 Set<String> sortNameSet = getSortNameSet();
80 keywordSet.addAll(sortNameSet); 79 keywordSet.addAll(sortNameSet);
81 keywordSet.addAll(getStyleNameSet()); 80 keywordSet.addAll(getStyleNameSet());
@@ -88,14 +87,11 @@ public class SuggestConvertorService { @@ -88,14 +87,11 @@ public class SuggestConvertorService {
88 for (String keyword : keywordSet) { 87 for (String keyword : keywordSet) {
89 if (keyword.length() > 1 && !SuggestionConstants.IGNORE_KEYWORDS.contains(keyword) && CollectionUtils.isNotEmpty(tokens = analyzerHelper.getTokens(keyword, ANALYZER))) { 88 if (keyword.length() > 1 && !SuggestionConstants.IGNORE_KEYWORDS.contains(keyword) && CollectionUtils.isNotEmpty(tokens = analyzerHelper.getTokens(keyword, ANALYZER))) {
90 yohoKeywords.put(keyword, tokens); 89 yohoKeywords.put(keyword, tokens);
91 - if (sortNameSet.contains(keyword)) {  
92 - filterSortNameSet.add(keyword);  
93 - }  
94 } 90 }
95 } 91 }
96 92
97 logger.info("[func=buildYohoKeywordBO][yohoKeywordsSize={}]", yohoKeywords.size()); 93 logger.info("[func=buildYohoKeywordBO][yohoKeywordsSize={}]", yohoKeywords.size());
98 - return new YohoKeywordsBO(yohoKeywords, filterSortNameSet); 94 + return new YohoKeywordsBO(yohoKeywords, new HashSet<>());
99 } 95 }
100 96
101 private Set<String> getSortNameSet() { 97 private Set<String> getSortNameSet() {
@@ -10,6 +10,7 @@ search.suggestion.consumer.parametermake.enable=true @@ -10,6 +10,7 @@ search.suggestion.consumer.parametermake.enable=true
10 search.suggestion.consumer.shopname.enable=true 10 search.suggestion.consumer.shopname.enable=true
11 search.suggestion.consumer.productname.enable=true 11 search.suggestion.consumer.productname.enable=true
12 search.suggestion.consumer.brandwithsortname.enable=true 12 search.suggestion.consumer.brandwithsortname.enable=true
  13 +search.suggestion.consumer.stylename.enable=true
13 14
14 # open increasement keyword spider 15 # open increasement keyword spider
15 search.suggestion.increasement.spider.open=true 16 search.suggestion.increasement.spider.open=true