...
|
...
|
@@ -2,6 +2,7 @@ package com.yoho.search.spider.conversation; |
|
|
|
|
|
import com.yoho.search.base.utils.DateUtil;
|
|
|
import com.yoho.search.base.utils.ISearchConstants;
|
|
|
import com.yoho.search.base.utils.MD5Util;
|
|
|
import com.yoho.search.consumer.index.common.AnalyzerHelper;
|
|
|
import com.yoho.search.consumer.index.common.IYohoIndexService;
|
|
|
import com.yoho.search.consumer.service.base.*;
|
...
|
...
|
@@ -50,19 +51,24 @@ public class SuggestConvertorService { |
|
|
private SuggestConversionService suggestConversionService;
|
|
|
|
|
|
@Autowired
|
|
|
private SuggestConversionCustomService suggestConversionCustomService;
|
|
|
|
|
|
@Autowired
|
|
|
private IYohoIndexService indexService;
|
|
|
|
|
|
public void insertOrUpdateConversion(String source, String dest){
|
|
|
SuggestConversion suggestConversion = suggestConversionService.selectBySource(source);
|
|
|
if(suggestConversion == null){
|
|
|
suggestConversion = new SuggestConversion();
|
|
|
public void insertOrUpdateConversion(String source, String dest) {
|
|
|
SuggestConversionCustom suggestConversion = suggestConversionCustomService.selectBySource(source);
|
|
|
if (suggestConversion == null) {
|
|
|
suggestConversion = new SuggestConversionCustom();
|
|
|
suggestConversion.setSource(source);
|
|
|
suggestConversion.setDest(dest);
|
|
|
suggestConversion.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
|
|
suggestConversion.setStatus(1);
|
|
|
suggestConversionService.insertBatch(Arrays.asList(suggestConversion));
|
|
|
}
|
|
|
else{
|
|
|
} else {
|
|
|
suggestConversion.setDest(dest);
|
|
|
suggestConversion.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
|
|
suggestConversion.setStatus(1);
|
|
|
suggestConversionService.updateByPrimaryKey(suggestConversion);
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -235,21 +241,31 @@ public class SuggestConvertorService { |
|
|
|
|
|
public boolean addOrUpdateIndex(String keyword) {
|
|
|
Assert.notNull(keyword);
|
|
|
SuggestConversion suggestConversion = suggestConversionService.selectBySource(keyword);
|
|
|
if (suggestConversion == null) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
Map<String, String> dataMap = new HashMap<>();
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
SuggestConversion suggestConversion;
|
|
|
SuggestConversionCustom suggestConversionCustom = suggestConversionCustomService.selectBySource(keyword);
|
|
|
if (suggestConversionCustom != null) {
|
|
|
dataMap.put("source", suggestConversionCustom.getSource());
|
|
|
dataMap.put("dest", suggestConversionCustom.getDest());
|
|
|
dataMap.put("updateTime", suggestConversionCustom.getUpdateTime());
|
|
|
dataMap.put("status", suggestConversionCustom.getStatus());
|
|
|
} else if ((suggestConversion = suggestConversionService.selectBySource(keyword)) != null) {
|
|
|
dataMap.put("source", suggestConversion.getSource());
|
|
|
dataMap.put("dest", suggestConversion.getDest());
|
|
|
indexService.updateIndexData(ISearchConstants.INDEX_NAME_CONVERSION, suggestConversion.getId().toString(), dataMap);
|
|
|
return true;
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
|
return false;
|
|
|
dataMap.put("updateTime", suggestConversion.getUpdateTime());
|
|
|
dataMap.put("status", Integer.valueOf(1));
|
|
|
}
|
|
|
|
|
|
if (!dataMap.isEmpty()) {
|
|
|
try {
|
|
|
indexService.updateIndexData(ISearchConstants.INDEX_NAME_CONVERSION, MD5Util.string2MD5(dataMap.get("source").toString().trim().toLowerCase()), dataMap);
|
|
|
return true;
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> explainConversion(String keyword) {
|
...
|
...
|
|