Authored by wangnan9279

delete tbl

... ... @@ -36,8 +36,6 @@ public class YohoIndexDataLoader implements IYohoIndexDataLoader, ApplicationEve
private ExecutorService threadPool;
private static final ExecutorService tblThreadPool = Executors.newFixedThreadPool(1);
private static final int MAX_RETRY_TIMES = 5;
private ApplicationEventPublisher publisher;
... ... @@ -66,7 +64,7 @@ public class YohoIndexDataLoader implements IYohoIndexDataLoader, ApplicationEve
int limit = rebuildPageSize == null ? 500 : rebuildPageSize;
// 如果是全球购的,则只用1个线程就行了【全球购的数据库太烂,并发太高返回不了】
ExecutorService executorService = yohoIndexName.equalsIgnoreCase(ISearchConstants.INDEX_NAME_TBLPRODUCT) ? tblThreadPool : threadPool;
ExecutorService executorService = threadPool;
List<Future<Boolean>> futureResults = new ArrayList<Future<Boolean>>();
for (IIndexBuilder indexBuilder : indexBuilderList) {
// 2、获取总的记录数,设置每页取1条,因为无需拿数据
... ... @@ -107,7 +105,6 @@ public class YohoIndexDataLoader implements IYohoIndexDataLoader, ApplicationEve
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
threadPool.shutdown();
tblThreadPool.shutdown();
}));
return result;
... ...
package com.yoho.search.consumer.index.fullbuild.tbl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.HttpClientUtils;
import com.yoho.search.base.utils.MD5Util;
import com.yoho.search.consumer.index.fullbuild.IIndexBuilder;
import com.yoho.search.consumer.service.logicService.common.ConsumerConfiger;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* 全球购索引构建器(通过调用外部全球购接口的方式重建)
*/
@Component
public class TblProductIndexBuilder extends IIndexBuilder {
private final Logger INDEX_REBUILD_LOG = LoggerFactory.getLogger("INDEX_REBULDER");
@Autowired
private ConsumerConfiger configurer;
@Override
public int getTotalCount() throws Exception {
return getCount();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
return getPageList(offset, limit);
}
/**
* 调接口建索引:获取总数量
*/
private int getCount() {
StringBuilder countUrl = new StringBuilder();
countUrl.append(configurer.getTblProductUrl());
countUrl.append("getproductscountforsearch?client_type=iphone&client_secret=");
String md5 = MD5Util.string2MD5("client_type=iphone&private_key=" + configurer.getTblPrimaryKey());
countUrl.append(md5);
INDEX_REBUILD_LOG.info("TblProductIndexBuilder getCount is [{}]", countUrl.toString());
String countJson = HttpClientUtils.getMethod(countUrl.toString());
if (StringUtils.isNotBlank(countJson)) {
JSONObject jsonObject = JSON.parseObject(countJson);
String count = jsonObject.get("data").toString();
if (StringUtils.isNotBlank(count)) {
int totalCount = Integer.parseInt(count);
return totalCount;
}
}
return 0;
}
/**
* 调接口建索引:调接口获取数据
*/
private List<Map> getPageList(int start, int limit) {
StringBuilder url = new StringBuilder();
url.append(configurer.getTblProductUrl())
.append("getproductslistforsearch?client_type=iphone")
.append("&limit=")
.append(limit)
.append("&offset=")
.append(start);
StringBuilder param = new StringBuilder();
param.append("client_type=iphone")
.append("&limit=")
.append(limit)
.append("&offset=")
.append(start)
.append("&private_key=")
.append(configurer.getTblPrimaryKey());
String md5 = MD5Util.string2MD5(param.toString());
url.append("&client_secret=").append(md5);
INDEX_REBUILD_LOG.info("TblProductIndexBuilder getPageList is [{}]", url.toString());
String json = HttpClientUtils.getMethod(url.toString());
if (StringUtils.isBlank(json)) {
return null;
}
JSONObject jsonObject = JSON.parseObject(json);
String data = jsonObject.getString("data");
if (StringUtils.isBlank(data)) {
return null;
}
return JSONArray.parseArray(jsonObject.getString("data"), Map.class);
}
@Override
public String getId(Object object) {
return UUID.randomUUID().toString();
}
}
index:
analysis:
filter:
dynamic_synonym:
type: dynamic-synonym
synonym_expand: true
synonym_ignore_case: true
synonym_analyzer: ik_smart
dynamic_synonym_rewrite:
type: dynamic-synonym-rewrite
synonym_expand: true
synonym_ignore_case: true
synonym_analyzer: ik_smart
analyzer:
comma_spliter:
type: pattern
pattern: "[,|\\s]+"
ik_complex:
type: custom
tokenizer: ik_smart
filter:
- lowercase
- dynamic_synonym
- trim
- unique
ik_complex_search:
type: custom
tokenizer: ik_smart
filter:
- lowercase
- dynamic_synonym_rewrite
- trim
- unique
index.analysis.analyzer.default.type: keyword
{
"tblproduct": {
"_all": {
"enabled": false
},
"_source": {
"enabled": true
},
"properties": {
"product_skn": {
"type": "integer"
},
"product_name": {
"type": "text",
"analyzer": "ik_complex",
"search_analyzer": "ik_complex_search"
},
"goods_price": {
"type": "double"
},
"brand_id": {
"type": "long"
},
"site_id": {
"type": "long"
},
"sort_one": {
"type": "long"
},
"sort_two": {
"type": "long"
},
"sort_three": {
"type": "long"
},
"sort_four": {
"type": "long"
},
"is_limited": {
"type": "long"
},
"country_id": {
"type": "long"
},
"gender": {
"type": "keyword"
},
"currency_id": {
"type": "long"
},
"tag_price": {
"type": "double"
},
"orign_price": {
"type": "double"
},
"status": {
"type": "long"
},
"stock_status": {
"type": "long"
},
"update_time": {
"type": "long"
},
"shelf_time": {
"type": "long"
},
"color_ids": {
"type": "text",
"analyzer": "comma_spliter",
"fielddata": "true"
},
"is_global": {
"type": "keyword"
},
"skc": {
"properties": {
"cover": {
"type": "text"
},
"color": {
"type": "text"
},
"product_skc": {
"type": "text"
},
"format_cover": {
"type": "text"
},
"color_sys_id": {
"type": "text"
}
}
},
"size_list": {
"type": "keyword"
},
"format_cover": {
"type": "text"
},
"cover": {
"type": "text"
},
"is_plane": {
"type": "text"
},
"show_status": {
"type": "text"
}
}
}
}
\ No newline at end of file
... ... @@ -122,20 +122,6 @@
</index>
<index>
<name>tblproduct</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_replicas" value="1"/>
<property key="refresh_interval" value="10s"/>
<property key="translog.flush_threshold_size" value="100mb"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.tbl.TblProductIndexBuilder</builderClass>
<mappingFile>esmapping/tblproduct.json</mappingFile>
<analysisFile>analysis/tblproduct.yml</analysisFile>
<rebuildPageSize>500</rebuildPageSize>
</index>
<index>
<name>tblproductnew</name>
<properties>
<property key="number_of_shards" value="1"/>
... ...
... ... @@ -120,20 +120,6 @@
</index>
<index>
<name>tblproduct</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_replicas" value="${search.index.number_of_replicas}"/>
<property key="refresh_interval" value="${search.index.refresh_interval}"/>
<property key="translog.flush_threshold_size" value="${search.index.translog.flush_threshold_size}"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.tbl.TblProductIndexBuilder</builderClass>
<mappingFile>esmapping/tblproduct.json</mappingFile>
<analysisFile>analysis/tblproduct.yml</analysisFile>
<rebuildPageSize>500</rebuildPageSize>
</index>
<index>
<name>tblproductnew</name>
<properties>
<property key="number_of_shards" value="1"/>
... ...