|
|
package com.yoho.search.consumer.index.fullbuild;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.yoho.search.base.utils.MD5Util;
|
|
|
import com.yoho.search.consumer.index.common.IIndexBuilder;
|
|
|
import com.yoho.search.consumer.service.base.SuggestionKeywordsService;
|
|
|
import com.yoho.search.consumer.service.bo.SuggestIndexBO;
|
|
|
import com.yoho.search.dal.model.SuggestionKeywords;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Component
|
|
|
public class SuggestIndexBuilder extends IIndexBuilder {
|
...
|
...
|
@@ -23,17 +25,22 @@ public class SuggestIndexBuilder extends IIndexBuilder { |
|
|
|
|
|
@Override
|
|
|
public List<?> getPageLists(int offset, int limit) throws Exception {
|
|
|
List<SuggestionKeywords> list = suggestionKeywordsService.getPageLists(offset, limit);
|
|
|
//老的建议词的权重设为0【最低】
|
|
|
for (SuggestionKeywords suggestionKeyword : list) {
|
|
|
suggestionKeyword.setWeight(0);
|
|
|
List<SuggestionKeywords> guggestionKeywordList = suggestionKeywordsService.getPageLists(offset, limit);
|
|
|
List<SuggestIndexBO> results = new ArrayList<SuggestIndexBO>();
|
|
|
for (SuggestionKeywords kw : guggestionKeywordList) {
|
|
|
if (kw.getCount() == null || kw.getCount() == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
int type = -1;
|
|
|
int weight = -1;
|
|
|
results.add(new SuggestIndexBO(kw.getKeyword(), type, weight, kw.getCount()));
|
|
|
}
|
|
|
return list.stream().filter(item -> item.getCount() != null && item.getCount() > 0).collect(Collectors.toList());
|
|
|
return results;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String getId(Object object) {
|
|
|
return MD5Util.string2MD5(((SuggestionKeywords) object).getKeyword().trim().toLowerCase());
|
|
|
return MD5Util.string2MD5(((SuggestIndexBO) object).getKeyword().trim().toLowerCase());
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|