Authored by Gino Zhang

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

... ... @@ -17,6 +17,7 @@ public enum KeywordType {
ProductKeywordToken(5, 6,SuggestionConstants.PRODUCTKEYWORD_TOKEN_ENABLED_KEY),
BrandKeywordToken(6, 6, SuggestionConstants.BRANDKEYWORD_TOKEN_ENABLED_KEY),
StyleName(13, 4, SuggestionConstants.STYLENAME_ENABLED_KEY),
ParameterMake(12, 3, SuggestionConstants.PARAMETERMAKE_ENABLED_KEY),
ProductName(8, 1, SuggestionConstants.PRODUCTNAME_ENABLED_KEY),
... ...
... ... @@ -16,7 +16,7 @@ public class SuggestionConstants {
public static final Integer VALID_STATUS = Integer.valueOf(1);
public static final List<String> IGNORE_KEYWORDS = Arrays.asList("其他","正常","中文","中国","普通","2%","时尚");
public static final List<String> IGNORE_KEYWORDS = Arrays.asList("其他","正常","中文","中国","普通","2%","时尚","标准","标准款","模型","其它");
/**
* 返回智能搜索词的数量
... ... @@ -38,6 +38,7 @@ public class SuggestionConstants {
public static String SHOPNAME_ENABLED_KEY = "search.suggestion.consumer.shopname.enable";
public static String PRODUCTNAME_ENABLED_KEY = "search.suggestion.consumer.productname.enable";
public static String PARAMETERMAKE_ENABLED_KEY = "search.suggestion.consumer.parametermake.enable";
public static String STYLENAME_ENABLED_KEY = "search.suggestion.consumer.stylename.enable";
public static int FETCH_HOTKEYWORD_COUNT = 10000;
... ...
package com.yoho.search.consumer.suggests.discover;
import com.yoho.search.consumer.service.base.StyleService;
import com.yoho.search.consumer.suggests.common.KeywordType;
import com.yoho.search.consumer.suggests.common.SuggestionConstants;
import com.yoho.search.dal.model.Style;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Created by ginozhang on 2016/11/25.
*/
@Component
public class StyleNameSuggestionDiscoverer extends AbstractSuggestionDiscoverer {
@Autowired
private StyleService styleService;
@Override
public int count() {
return styleService.count();
}
@Override
public Set<String> getSuggestWordSet(int pageNo, int batchSize) {
Set<String> styleNameSet = new HashSet<>(batchSize);
int start = (pageNo - 1) * batchSize;
List<Style> styleList = styleService.getStylePageLists(start, batchSize);
if (CollectionUtils.isNotEmpty(styleList)) {
for (Style style : styleList) {
if (style.getStyleName() != null && style.getStyleName().length() > 1) {
if (!SuggestionConstants.IGNORE_KEYWORDS.contains(style.getStyleName())) {
styleNameSet.add(style.getStyleName());
}
}
}
}
return styleNameSet;
}
@Override
public KeywordType getKeywordType() {
return KeywordType.StyleName;
}
}
... ...
... ... @@ -75,7 +75,6 @@ public class SuggestConvertorService {
public YohoKeywordsBO buildYohoKeywordBO() {
Set<String> keywordSet = new HashSet<>(3000);
Set<String> filterSortNameSet = new HashSet<>(300);
Set<String> sortNameSet = getSortNameSet();
keywordSet.addAll(sortNameSet);
keywordSet.addAll(getStyleNameSet());
... ... @@ -88,14 +87,11 @@ public class SuggestConvertorService {
for (String keyword : keywordSet) {
if (keyword.length() > 1 && !SuggestionConstants.IGNORE_KEYWORDS.contains(keyword) && CollectionUtils.isNotEmpty(tokens = analyzerHelper.getTokens(keyword, ANALYZER))) {
yohoKeywords.put(keyword, tokens);
if (sortNameSet.contains(keyword)) {
filterSortNameSet.add(keyword);
}
}
}
logger.info("[func=buildYohoKeywordBO][yohoKeywordsSize={}]", yohoKeywords.size());
return new YohoKeywordsBO(yohoKeywords, filterSortNameSet);
return new YohoKeywordsBO(yohoKeywords, new HashSet<>());
}
private Set<String> getSortNameSet() {
... ...
... ... @@ -10,6 +10,7 @@ search.suggestion.consumer.parametermake.enable=true
search.suggestion.consumer.shopname.enable=true
search.suggestion.consumer.productname.enable=true
search.suggestion.consumer.brandwithsortname.enable=true
search.suggestion.consumer.stylename.enable=true
# open increasement keyword spider
search.suggestion.increasement.spider.open=true
\ No newline at end of file
... ...