Authored by Gino Zhang

增加一个管理suggest_word_def的restful接口

package com.yoho.search.consumer.restapi;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yoho.error.event.SearchEvent;
import com.yoho.error.event.SearchLogsEvent;
import com.yoho.search.base.utils.EventReportEnum;
... ... @@ -16,7 +15,6 @@ import com.yoho.search.consumer.job.SuggestionDiscoveryJob;
import com.yoho.search.consumer.service.base.ProductIndexService;
import com.yoho.search.consumer.service.base.SuggestWordDefService;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.consumer.service.bo.SuggestIndexBO;
import com.yoho.search.consumer.service.logic.ProductIndexLogicService;
import com.yoho.search.consumer.suggests.common.KeywordType;
import com.yoho.search.consumer.suggests.counter.KeywordCounterService;
... ... @@ -318,9 +316,15 @@ public class IndexController implements ApplicationEventPublisherAware {
suggestWordDef.setWeight(KeywordType.Customized.getWeightValue());
suggestWordDefService.insertBatch(Arrays.asList(suggestWordDef));
Map<String, Object> dataMap = new HashMap();
dataMap.put("keyword", keyword);
dataMap.put("type", suggestWordDef.getType());
dataMap.put("weight", suggestWordDef.getWeight());
dataMap.put("count", suggestWordDef.getCount());
dataMap.put("countForApp", suggestWordDef.getCountForApp());
dataMap.put("countForBlk", suggestWordDef.getCountForBlk());
SuggestIndexBO suggestIndexBO = new SuggestIndexBO(suggestWordDef.getKeyword(), suggestWordDef.getType(), suggestWordDef.getWeight(), suggestWordDef.getCount(), suggestWordDef.getCountForApp(), suggestWordDef.getCountForBlk());
yohoIndexService.addIndexData(ISearchConstants.INDEX_NAME_SUGGEST, MD5Util.string2MD5(keyword.trim().toLowerCase()), JSONObject.toJSONString(suggestIndexBO));
yohoIndexService.addIndexData(ISearchConstants.INDEX_NAME_SUGGEST, MD5Util.string2MD5(keyword.trim().toLowerCase()), dataMap);
}
return getResultMap(200, "success");
... ...