Authored by wangnan

整理代码

1 package com.yohomars.search.index.service.impl; 1 package com.yohomars.search.index.service.impl;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 -import com.yoho.error.event.SearchEvent;  
5 import com.yohomars.search.es.IElasticsearchClient; 4 import com.yohomars.search.es.IElasticsearchClient;
6 import com.yohomars.search.index.builder.IIndexBuilder; 5 import com.yohomars.search.index.builder.IIndexBuilder;
7 import com.yohomars.search.index.model.ESBluk; 6 import com.yohomars.search.index.model.ESBluk;
8 -import com.yohomars.search.utils.EventReportEnum;  
9 import com.yohomars.search.utils.ISearchConstans; 7 import com.yohomars.search.utils.ISearchConstans;
10 import com.yohomars.search.utils.PerformanceMonitor; 8 import com.yohomars.search.utils.PerformanceMonitor;
11 import org.elasticsearch.action.bulk.BulkResponse; 9 import org.elasticsearch.action.bulk.BulkResponse;
@@ -14,8 +12,6 @@ import org.slf4j.LoggerFactory; @@ -14,8 +12,6 @@ import org.slf4j.LoggerFactory;
14 import org.springframework.beans.BeansException; 12 import org.springframework.beans.BeansException;
15 import org.springframework.context.ApplicationContext; 13 import org.springframework.context.ApplicationContext;
16 import org.springframework.context.ApplicationContextAware; 14 import org.springframework.context.ApplicationContextAware;
17 -import org.springframework.context.ApplicationEventPublisher;  
18 -import org.springframework.context.ApplicationEventPublisherAware;  
19 import org.springframework.stereotype.Component; 15 import org.springframework.stereotype.Component;
20 16
21 import java.util.ArrayList; 17 import java.util.ArrayList;
@@ -26,14 +22,12 @@ import java.util.concurrent.Executors; @@ -26,14 +22,12 @@ import java.util.concurrent.Executors;
26 import java.util.concurrent.Future; 22 import java.util.concurrent.Future;
27 23
28 @Component 24 @Component
29 -public class YohoIndexDataLoader implements ApplicationEventPublisherAware, ApplicationContextAware { 25 +public class YohoIndexDataLoader implements ApplicationContextAware {
30 26
31 private final Logger INDEX_REBUILD_LOG = LoggerFactory.getLogger("INDEX_REBULDER"); 27 private final Logger INDEX_REBUILD_LOG = LoggerFactory.getLogger("INDEX_REBULDER");
32 28
33 private static final ExecutorService threadPool = Executors.newFixedThreadPool(ISearchConstans.SEARCH_INDEX_BATCH_MAX_THREAD_SIZE); 29 private static final ExecutorService threadPool = Executors.newFixedThreadPool(ISearchConstans.SEARCH_INDEX_BATCH_MAX_THREAD_SIZE);
34 30
35 - ApplicationEventPublisher publisher;  
36 -  
37 ApplicationContext applicationContext; 31 ApplicationContext applicationContext;
38 32
39 private PerformanceMonitor performanceMonitor = new PerformanceMonitor("YohoIndexDataLoader",0,INDEX_REBUILD_LOG); 33 private PerformanceMonitor performanceMonitor = new PerformanceMonitor("YohoIndexDataLoader",0,INDEX_REBUILD_LOG);
@@ -119,9 +113,6 @@ public class YohoIndexDataLoader implements ApplicationEventPublisherAware, Appl @@ -119,9 +113,6 @@ public class YohoIndexDataLoader implements ApplicationEventPublisherAware, Appl
119 // BulkResponse bulkResponse = client.addIndexDataBean(tempIndexRealName, yohoIndexName, dataList); 113 // BulkResponse bulkResponse = client.addIndexDataBean(tempIndexRealName, yohoIndexName, dataList);
120 if(bulkResponse.hasFailures()){ 114 if(bulkResponse.hasFailures()){
121 Exception e = new Exception(String.format("addIndexDataBean has fail,[yohoIndexName=[%s]],[pageNo=%s],[failureMessage=%s]", yohoIndexName,pageNo,bulkResponse.buildFailureMessage())); 115 Exception e = new Exception(String.format("addIndexDataBean has fail,[yohoIndexName=[%s]],[pageNo=%s],[failureMessage=%s]", yohoIndexName,pageNo,bulkResponse.buildFailureMessage()));
122 - publisher.publishEvent(new SearchEvent(EventReportEnum.YOHOINDEXDATALOADER_DOLOADDATA.getEventName(),  
123 - EventReportEnum.YOHOINDEXDATALOADER_DOLOADDATA.getFunctionName(),  
124 - EventReportEnum.YOHOINDEXDATALOADER_DOLOADDATA.getMoudleName(),"exception",e,null));  
125 throw e; 116 throw e;
126 } 117 }
127 long end = System.currentTimeMillis(); 118 long end = System.currentTimeMillis();
@@ -143,13 +134,6 @@ public class YohoIndexDataLoader implements ApplicationEventPublisherAware, Appl @@ -143,13 +134,6 @@ public class YohoIndexDataLoader implements ApplicationEventPublisherAware, Appl
143 private void handelException(String yohoIndexName, int pageNo, Exception e) { 134 private void handelException(String yohoIndexName, int pageNo, Exception e) {
144 // 1、上报异常至日志 135 // 1、上报异常至日志
145 INDEX_REBUILD_LOG.error(e.getMessage(), e); 136 INDEX_REBUILD_LOG.error(e.getMessage(), e);
146 - // 2、上报异常至influxdb  
147 -// LogEvent event = new LogEvent.Builder("search_consumer").catalog("search_consumer").addArg("ip", LocalIp.getLocalIp()).addArg("yohoIndexName", yohoIndexName).addArg("pageNo", pageNo)  
148 -// .addArg("exception", e.getMessage()).build();  
149 -// publisher.publishEvent(event);  
150 - publisher.publishEvent(new SearchEvent(EventReportEnum.YOHOINDEXDATALOADER_HANDELEXCEPTION.getEventName(),  
151 - EventReportEnum.YOHOINDEXDATALOADER_HANDELEXCEPTION.getFunctionName(),  
152 - EventReportEnum.YOHOINDEXDATALOADER_HANDELEXCEPTION.getMoudleName(),"exception",e,"yohoIndexName="+yohoIndexName+"/pageNo="+pageNo));  
153 } 137 }
154 138
155 @Override 139 @Override
@@ -157,8 +141,4 @@ public class YohoIndexDataLoader implements ApplicationEventPublisherAware, Appl @@ -157,8 +141,4 @@ public class YohoIndexDataLoader implements ApplicationEventPublisherAware, Appl
157 this.applicationContext = applicationContext; 141 this.applicationContext = applicationContext;
158 } 142 }
159 143
160 - @Override  
161 - public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {  
162 - this.publisher = applicationEventPublisher;  
163 - }  
164 } 144 }
@@ -27,8 +27,6 @@ import org.elasticsearch.cluster.health.ClusterHealthStatus; @@ -27,8 +27,6 @@ import org.elasticsearch.cluster.health.ClusterHealthStatus;
27 import org.slf4j.Logger; 27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory; 28 import org.slf4j.LoggerFactory;
29 import org.springframework.beans.factory.annotation.Autowired; 29 import org.springframework.beans.factory.annotation.Autowired;
30 -import org.springframework.context.ApplicationEventPublisher;  
31 -import org.springframework.context.ApplicationEventPublisherAware;  
32 import org.springframework.stereotype.Component; 30 import org.springframework.stereotype.Component;
33 31
34 import javax.annotation.PostConstruct; 32 import javax.annotation.PostConstruct;
@@ -41,7 +39,7 @@ import java.util.concurrent.ConcurrentHashMap; @@ -41,7 +39,7 @@ import java.util.concurrent.ConcurrentHashMap;
41 import java.util.regex.Pattern; 39 import java.util.regex.Pattern;
42 40
43 @Component 41 @Component
44 -public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEventPublisherAware { 42 +public class YohoIndexServiceImpl implements IYohoIndexService {
45 43
46 private final Logger logger = LoggerFactory.getLogger(YohoIndexServiceImpl.class); 44 private final Logger logger = LoggerFactory.getLogger(YohoIndexServiceImpl.class);
47 45
@@ -54,12 +52,7 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent @@ -54,12 +52,7 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
54 @Autowired 52 @Autowired
55 private YohoIndexDataLoader yohoIndexDataLoader; 53 private YohoIndexDataLoader yohoIndexDataLoader;
56 54
57 - ApplicationEventPublisher publisher;  
58 55
59 - @Override  
60 - public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {  
61 - this.publisher = applicationEventPublisher;  
62 - }  
63 56
64 // 索引配置文件 57 // 索引配置文件
65 private String configFile = "index.xml"; 58 private String configFile = "index.xml";
1 -package com.yohomars.search.utils;  
2 -  
3 -public enum EventReportEnum {  
4 -  
5 - CUSTOMSIMPLECANALCLIENT_AFTERPROPERTIESSET("afterPropertiesSet","CustomSimpleCanalClient.afterPropertiesSet", MoudleEnum.producer),  
6 - CUSTOMSIMPLECANALCLIENT_STARTSHOPCLIENT("startShopClient","CustomSimpleCanalClient.startShopClient",MoudleEnum.producer),  
7 - CUSTOMSIMPLECANALCLIENT_STARTOPERATIONCLIENT("startOperationClient","CustomSimpleCanalClient.startOperationClient",MoudleEnum.producer),  
8 - CUSTOMSIMPLECANALCLIENT_STARTERPPRODUCTCLIENT("startErpproductClient","CustomSimpleCanalClient.startErpproductClient",MoudleEnum.producer),  
9 - CUSTOMSIMPLECANALCLIENT_HANDLECANALMESSAGE("handleCanalMessage","CustomSimpleCanalClient.handleCanalMessage",MoudleEnum.producer),  
10 - CUSTOMSIMPLECANALCLIENT_PUBLISHTOREDIS("publishToRedis","CustomSimpleCanalClient.publishToRedis",MoudleEnum.producer),  
11 - CUSTOMSIMPLECANALCLIENT_GETDELETEDATA("getDeleteData","CustomSimpleCanalClient.getDeleteData",MoudleEnum.producer),  
12 - CUSTOMSIMPLECANALCLIENT_GETUPDATEDATA("getUpdateData","CustomSimpleCanalClient.getUpdateData",MoudleEnum.producer),  
13 - CUSTOMSIMPLECANALCLIENT_GETDATA("getData","CustomSimpleCanalClient.getData",MoudleEnum.producer),  
14 -  
15 - INDEXREBUILDJOB_REBUILDINDEXWITHLOG("rebuildIndexWithlog","IndexRebuildJob.rebuildIndexWithlog",MoudleEnum.consumer),  
16 - TPLADAPTORJOB_GETTPLPRODUCTCOUNT("getTplProductCount","TplAdaptorJob.getTplProductCount",MoudleEnum.consumer),  
17 - TPLADAPTORJOB_GETPRODUCTINDEXLIST("getProductIndexList","TplAdaptorJob.getProductIndexList",MoudleEnum.consumer),  
18 - TPLADAPTORJOB_ADDPRODUCTINDEXINTOES("addProductIndexIntoEs","TplAdaptorJob.addProductIndexIntoEs",MoudleEnum.consumer),  
19 - ABSTRACTMQLISTENER_WAITINGREBUILDINGINDEX("waitingRebuildingIndex","AbstractMqListener.waitingRebuildingIndex",MoudleEnum.consumer),  
20 - ABSTRACTMQLISTENER_UPDATEPRODUCTINDEXWITHDATAMAP("updateProductIndexWithDataMap","AbstractMqListener.updateProductIndexWithDataMap",MoudleEnum.consumer),  
21 - ABSTRACTMQLISTENER_SENDPRODUCTINDEXMESSAGE("sendProductIndexMessage","AbstractMqListener.sendProductIndexMessage",MoudleEnum.consumer),  
22 - ACTIVITYPRODUCTMQLISTENER_ONMESSAGE("onMessage","ActivityProductMqListener.onMessage",MoudleEnum.consumer),  
23 - BRANDMQLISTENER_ONMESSAGE("onMessage","BrandMqListener.onMessage",MoudleEnum.consumer),  
24 - GOODSIMAGESMQLISTENER_ONMESSAGE("onMessage","GoodsImagesMqListener.onMessage",MoudleEnum.consumer),  
25 - GOODSMQLISTENER_ONMESSAGE("onMessage","GoodsMqListener.onMessage",MoudleEnum.consumer),  
26 - PARAMETERMAKEMQLISTENER_ONMESSAGE("onMessage","ParameterMakeMqListener.onMessage",MoudleEnum.consumer),  
27 - PRODUCTACTIVITIESLINKMQLISTENER_ONMESSAGE("onMessage","ProductActivitiesLinkMqListener.onMessage",MoudleEnum.consumer),  
28 - PRODUCTCOLORMQLISTENER_ONMESSAGE("onMessage","ProductColorMqListener.onMessage",MoudleEnum.consumer),  
29 - PRODUCTINDEXMQLISTENER_ONMESSAGE("onMessage","ProductIndexMqListener.onMessage",MoudleEnum.consumer),  
30 - PRODUCTKEYWORDSMQLISTENER_ONMESSAGE("onMessage","ProductKeywordsMqListener.onMessage",MoudleEnum.consumer),  
31 - PRODUCTMQLISTENER_ONMESSAGE("onMessage","ProductMqListener.onMessage",MoudleEnum.consumer),  
32 - PRODUCTPOOLDETAILMQLISTENER_ONMESSAGE("onMessage","ProductPoolDetailMqListener.onMessage",MoudleEnum.consumer),  
33 - PRODUCTMQLISTENER_UPDATEDATA("updateData","ProductMqListener.updateData",MoudleEnum.consumer),  
34 - PRODUCTPRICEMQLISTENER_ONMESSAGE("onMessage","ProductPriceMqListener.onMessage",MoudleEnum.consumer),  
35 - PRODUCTSEARCHMQLISTENER_ONMESSAGE("onMessage","ProductSearchMqListener.onMessage",MoudleEnum.consumer),  
36 - PRODUCTSORTMQLISTENER_ONMESSAGE("onMessage","ProductSortMqListener.onMessage",MoudleEnum.consumer),  
37 - PRODUCTSTANDARDRELATIONMQLISTENER_ONMESSAGE("onMessage","ProductStandardRelationMqListener.onMessage",MoudleEnum.consumer),  
38 - PRODUCTSTYLERELATIONMQLISTENER_ONMESSAGE("onMessage","ProductStyleRelationMqListener.onMessage",MoudleEnum.consumer),  
39 - SEARCHACTIONMQLISTENER_ONMESSAGE("onMessage","SearchActionMqListener.onMessage",MoudleEnum.consumer),  
40 - SIZEMQLISTENER_ONMESSAGE("onMessage","SizeMqListener.onMessage",MoudleEnum.consumer),  
41 - STORAGEMQLISTENER_ONMESSAGE("onMessage","StorageMqListener.onMessage",MoudleEnum.consumer),  
42 - STYLEMQLISTENER_ONMESSAGE("onMessage","StyleMqListener.onMessage",MoudleEnum.consumer),  
43 - YOHOODPRODUCTMQLISTENER_ONMESSAGE("onMessage","YohoodProductMqListener.onMessage",MoudleEnum.consumer),  
44 - YOHOODPRODUCTMQLISTENER_UPDATEINDEX("updateIndex","YohoodProductMqListener.updateIndex",MoudleEnum.consumer),  
45 - STANDARDMQLISTENER_ONMESSAGE("onMessage","StandardMqListener.onMessage",MoudleEnum.consumer),  
46 - STORAGESKUINDEXSERVICE_UPDATESTORAGESKUINDEXBYPRODUCTID("updateStorageSkuIndexByProductId","StorageSkuIndexService.updateStorageSkuIndexByProductId",MoudleEnum.consumer),  
47 - STORAGESKUINDEXSERVICE_UPDATESTORAGESKUINDEX("updateStorageSkuIndex","StorageSkuIndexService.updateStorageSkuIndex",MoudleEnum.consumer),  
48 - INDEXCONTROLLER_INDEX_CREATE("/index/create","IndexController.create",MoudleEnum.consumer),  
49 - INDEXCONTROLLER_INDEX_EXIST("/index/exist","IndexController.exist",MoudleEnum.consumer),  
50 - INDEXCONTROLLER_INDEX_REBUILD("/index/rebuild","IndexController.rebuild",MoudleEnum.consumer),  
51 - INDEXCONTROLLER_INDEX_UPDATE("/index/update","IndexController.update",MoudleEnum.consumer),  
52 - BRANDCONTROLLER_BRAND_1("/brand/{brandId}","BrandController.brand",MoudleEnum.service),  
53 - BRANDCONTROLLER_BRAND_2("/brand/{start}/{size}","BrandController.brand",MoudleEnum.service),  
54 - BRANDCONTROLLER_BRAND_LIST("/brand/list","BrandController.list",MoudleEnum.service),  
55 - SEARCHCONTROLLER_SEARCHOLD("/searchOld","SearchController.searchProducts",MoudleEnum.service),  
56 - SEARCHCONTROLLER_SEARCH("/search","SearchController.searchProductsNew",MoudleEnum.service),  
57 - SEARCHCONTROLLER_DISCOUNT("/discount","SearchController.discount",MoudleEnum.service),  
58 - SEARCHCONTROLLER_RECENT("/recent","SearchController.recent",MoudleEnum.service),  
59 - SEARCHCONTROLLER_NEW_SHELVE("/new-shelve","SearchController.searchNewestProductWithDiffBrand",MoudleEnum.service),  
60 - SEARCHCONTROLLER_NEW_PRODUCT("/new_product","SearchController.searchNewestProductWithParamBrand",MoudleEnum.service),  
61 - SEARCHCONTROLLER_BRANDS("/brands","SearchController.brands",MoudleEnum.service),  
62 - SEARCHCONTROLLER_GROUP_BRANDS("/group_brands","SearchController.groupBrands",MoudleEnum.service),  
63 - SEARCHCONTROLLER_SORTGROUP("/sortgroup","SearchController.sortGroup",MoudleEnum.service),  
64 - SEARCHCONTROLLER_COUNT("/count","SearchController.searchCount",MoudleEnum.service),  
65 - SEARCHCONTROLLER_SUGGEST("/suggest","SearchController.suggest",MoudleEnum.service),  
66 - SEARCHCONTROLLER_SHOPS("/shops","SearchController.shops",MoudleEnum.service),  
67 - SEARCHCONTROLLER_GROUP_SHOPS("/group_shops","SearchController.groupShops",MoudleEnum.service),  
68 - SEARCHCONTROLLER_SORT_SIZE_PRODUCTS("/sort_size_products","SearchController.sort_size_products",MoudleEnum.service),  
69 - TBLPRODUCTCONTROLLER_TBLPRODUCT_SEARCH("/tblproduct/search","TblProductController.search",MoudleEnum.service),  
70 - TBLPRODUCTCONTROLLER_TBLPRODUCT_UPDATE("/tblproduct/update/{product_skn}","TblProductController.updateIndex",MoudleEnum.service),  
71 - PRODUCTINDEXSERVICEIMPL_GETSEARCHAPIRESULT("getSearchApiResult","ProductIndexServiceImpl.getSearchApiResult",MoudleEnum.service),  
72 - AGGREGATIONSERVICE_GETAGGNAMEANDRESPONSE("getAggNameAndResponse","AggregationService.getAggNameAndResponse",MoudleEnum.service),  
73 - AGGREGATIONSERVICE_GETAGGNAMEANDRESPONSEWITHOUTCACHE("getAggNameAndResponseWithOutCache","AggregationService.getAggNameAndResponseWithOutCache",MoudleEnum.service),  
74 - SEARCHCOMMONSERVICE_DOSEARCH("doSearch","SearchCommonService.doSearch",MoudleEnum.service),  
75 -  
76 - YOHOINDEXSERVICEIMPL_REBUILD("rebuild","YohoIndexServiceImpl.rebuild",MoudleEnum.core),  
77 - YOHOINDEXSERVICEIMPL_CONFIGURE("configure","YohoIndexServiceImpl.configure",MoudleEnum.core),  
78 - DATASYNTASKTHREAD_RUN("run","DataSynTaskThread.run",MoudleEnum.core),  
79 - YOHOINDEXIMPL_GETINDEXBUILDER("getIndexBuilder","YohoIndexImpl.getIndexBuilder",MoudleEnum.core),  
80 - YOHOINDEXDATALOADER_DOLOADDATA("doLoadData","YohoIndexDataLoader.doLoadData",MoudleEnum.core),  
81 - YOHOINDEXDATALOADER_HANDELEXCEPTION("handelException","YohoIndexDataLoader.handelException",MoudleEnum.core);  
82 -  
83 -  
84 - private String eventName;  
85 - private String functionName;  
86 - private String moudleName;  
87 - EventReportEnum(String eventName,String functionName,String moudleName){  
88 - this.eventName=eventName;  
89 - this.functionName=functionName;  
90 - this.moudleName=moudleName;  
91 - }  
92 - public String getEventName() {  
93 - return eventName;  
94 - }  
95 - public String getFunctionName() {  
96 - return functionName;  
97 - }  
98 - public String getMoudleName() {  
99 - return moudleName;  
100 - }  
101 -  
102 -}  
1 -package com.yoho.search.dal.model;  
2 -  
3 -public class SearchAction {  
4 - private Integer id;  
5 -  
6 - private Integer productSkn;  
7 -  
8 - private Integer objectId;  
9 -  
10 - private Integer pid;  
11 -  
12 - private Byte status;  
13 -  
14 - private Integer createTime;  
15 -  
16 - public Integer getId() {  
17 - return id;  
18 - }  
19 -  
20 - public void setId(Integer id) {  
21 - this.id = id;  
22 - }  
23 -  
24 - public Integer getProductSkn() {  
25 - return productSkn;  
26 - }  
27 -  
28 - public void setProductSkn(Integer productSkn) {  
29 - this.productSkn = productSkn;  
30 - }  
31 -  
32 - public Integer getObjectId() {  
33 - return objectId;  
34 - }  
35 -  
36 - public void setObjectId(Integer objectId) {  
37 - this.objectId = objectId;  
38 - }  
39 -  
40 - public Integer getPid() {  
41 - return pid;  
42 - }  
43 -  
44 - public void setPid(Integer pid) {  
45 - this.pid = pid;  
46 - }  
47 -  
48 - public Byte getStatus() {  
49 - return status;  
50 - }  
51 -  
52 - public void setStatus(Byte status) {  
53 - this.status = status;  
54 - }  
55 -  
56 - public Integer getCreateTime() {  
57 - return createTime;  
58 - }  
59 -  
60 - public void setCreateTime(Integer createTime) {  
61 - this.createTime = createTime;  
62 - }  
63 -}  
1 -package com.yoho.search.dal.model;  
2 -  
3 -import java.io.Serializable;  
4 -  
5 -public class SearchAdmin implements Serializable {  
6 - /**  
7 - *  
8 - */  
9 - private static final long serialVersionUID = 1L;  
10 -  
11 - private Long id;  
12 -  
13 - private String sceneCode;  
14 -  
15 - private String fieldName1;  
16 -  
17 - private Long weight1;  
18 -  
19 - private String fieldName2;  
20 -  
21 - private Long weight2;  
22 -  
23 - private String fieldName3;  
24 -  
25 - private Long weight3;  
26 -  
27 - private String fieldName4;  
28 -  
29 - private Long weight4;  
30 -  
31 - private String fieldName5;  
32 -  
33 - private Long weight5;  
34 -  
35 - public Long getId() {  
36 - return id;  
37 - }  
38 -  
39 - public void setId(Long id) {  
40 - this.id = id;  
41 - }  
42 -  
43 - public String getSceneCode() {  
44 - return sceneCode;  
45 - }  
46 -  
47 - public void setSceneCode(String sceneCode) {  
48 - this.sceneCode = sceneCode == null ? null : sceneCode.trim();  
49 - }  
50 -  
51 - public String getFieldName1() {  
52 - return fieldName1;  
53 - }  
54 -  
55 - public void setFieldName1(String fieldName1) {  
56 - this.fieldName1 = fieldName1 == null ? null : fieldName1.trim();  
57 - }  
58 -  
59 - public Long getWeight1() {  
60 - return weight1;  
61 - }  
62 -  
63 - public void setWeight1(Long weight1) {  
64 - this.weight1 = weight1;  
65 - }  
66 -  
67 - public String getFieldName2() {  
68 - return fieldName2;  
69 - }  
70 -  
71 - public void setFieldName2(String fieldName2) {  
72 - this.fieldName2 = fieldName2 == null ? null : fieldName2.trim();  
73 - }  
74 -  
75 - public Long getWeight2() {  
76 - return weight2;  
77 - }  
78 -  
79 - public void setWeight2(Long weight2) {  
80 - this.weight2 = weight2;  
81 - }  
82 -  
83 - public String getFieldName3() {  
84 - return fieldName3;  
85 - }  
86 -  
87 - public void setFieldName3(String fieldName3) {  
88 - this.fieldName3 = fieldName3 == null ? null : fieldName3.trim();  
89 - }  
90 -  
91 - public Long getWeight3() {  
92 - return weight3;  
93 - }  
94 -  
95 - public void setWeight3(Long weight3) {  
96 - this.weight3 = weight3;  
97 - }  
98 -  
99 - public String getFieldName4() {  
100 - return fieldName4;  
101 - }  
102 -  
103 - public void setFieldName4(String fieldName4) {  
104 - this.fieldName4 = fieldName4 == null ? null : fieldName4.trim();  
105 - }  
106 -  
107 - public Long getWeight4() {  
108 - return weight4;  
109 - }  
110 -  
111 - public void setWeight4(Long weight4) {  
112 - this.weight4 = weight4;  
113 - }  
114 -  
115 - public String getFieldName5() {  
116 - return fieldName5;  
117 - }  
118 -  
119 - public void setFieldName5(String fieldName5) {  
120 - this.fieldName5 = fieldName5 == null ? null : fieldName5.trim();  
121 - }  
122 -  
123 - public Long getWeight5() {  
124 - return weight5;  
125 - }  
126 -  
127 - public void setWeight5(Long weight5) {  
128 - this.weight5 = weight5;  
129 - }  
130 -}  
@@ -24,17 +24,17 @@ public class IndexRebuildJob { @@ -24,17 +24,17 @@ public class IndexRebuildJob {
24 24
25 25
26 /** 26 /**
27 - * 定时任务重建所有索引(每5分钟执行一次) 27 + * 定时任务重建所有索引(每10分钟执行一次)
28 */ 28 */
29 @Scheduled(cron = "0 0/10 * * * ?") 29 @Scheduled(cron = "0 0/10 * * * ?")
30 public void execute() { 30 public void execute() {
31 long begin = System.currentTimeMillis(); 31 long begin = System.currentTimeMillis();
32 logger.info("indexRebuildJob execute start----[begin={}]", begin); 32 logger.info("indexRebuildJob execute start----[begin={}]", begin);
33 - this.rebuildIndex(ISearchConstans.INDEX_NAME_BIZAREA);  
34 - this.rebuildIndex(ISearchConstans.INDEX_NAME_COMMENT);  
35 - this.rebuildIndex(ISearchConstans.INDEX_NAME_LINE);  
36 this.rebuildIndex(ISearchConstans.INDEX_NAME_STORE); 33 this.rebuildIndex(ISearchConstans.INDEX_NAME_STORE);
37 - this.rebuildIndex(ISearchConstans.INDEX_NAME_TOPIC); 34 + //this.rebuildIndex(ISearchConstans.INDEX_NAME_BIZAREA);
  35 + //this.rebuildIndex(ISearchConstans.INDEX_NAME_COMMENT);
  36 + //this.rebuildIndex(ISearchConstans.INDEX_NAME_LINE);
  37 + //this.rebuildIndex(ISearchConstans.INDEX_NAME_TOPIC);
38 logger.info("indexRebuildJob execute end----[end={}][cost={}ms]", System.currentTimeMillis(), (System.currentTimeMillis() - begin)); 38 logger.info("indexRebuildJob execute end----[end={}][cost={}ms]", System.currentTimeMillis(), (System.currentTimeMillis() - begin));
39 } 39 }
40 40
@@ -10,24 +10,17 @@ import org.elasticsearch.action.get.MultiGetResponse; @@ -10,24 +10,17 @@ import org.elasticsearch.action.get.MultiGetResponse;
10 import org.elasticsearch.action.suggest.SuggestResponse; 10 import org.elasticsearch.action.suggest.SuggestResponse;
11 import org.elasticsearch.search.suggest.Suggest; 11 import org.elasticsearch.search.suggest.Suggest;
12 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
13 -import org.springframework.context.ApplicationEventPublisher;  
14 -import org.springframework.context.ApplicationEventPublisherAware;  
15 import org.springframework.stereotype.Service; 13 import org.springframework.stereotype.Service;
16 14
17 import java.util.*; 15 import java.util.*;
18 16
19 @Service 17 @Service
20 -public class SearchCommonService implements ApplicationEventPublisherAware { 18 +public class SearchCommonService{
21 19
22 @Autowired 20 @Autowired
23 private IYohoIndexService yohoIndexService; 21 private IYohoIndexService yohoIndexService;
24 22
25 - private ApplicationEventPublisher publisher;  
26 23
27 - @Override  
28 - public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {  
29 - this.publisher = applicationEventPublisher;  
30 - }  
31 24
32 private void publishSearchResultEvent(final String indexName, SearchParam searchParam, SearchResult searchResult) { 25 private void publishSearchResultEvent(final String indexName, SearchParam searchParam, SearchResult searchResult) {
33 if (searchParam == null || searchResult == null) { 26 if (searchParam == null || searchResult == null) {
@@ -429,7 +429,6 @@ public class SearchServiceHelper { @@ -429,7 +429,6 @@ public class SearchServiceHelper {
429 store.setStoreName("name"); 429 store.setStoreName("name");
430 store.setLatitude(123.2); 430 store.setLatitude(123.2);
431 store.setLongitude(321.1); 431 store.setLongitude(321.1);
432 -  
433 jsonBuild.startObject().field("id", store.getId()).field("name", store.getStoreName()).startArray("location").value(store.getLatitude()).value(store.getLongitude()).endArray() 432 jsonBuild.startObject().field("id", store.getId()).field("name", store.getStoreName()).startArray("location").value(store.getLatitude()).value(store.getLongitude()).endArray()
434 .endObject(); 433 .endObject();
435 jsonData = jsonBuild.string(); 434 jsonData = jsonBuild.string();