Authored by wangnan

新增promotiontype索引,修改原来的promotion索引为zqname索引

package com.yoho.search.consumer.index.fullbuild;
import com.yoho.search.consumer.index.common.IIndexBuilder;
import com.yoho.search.consumer.service.daoService.PromotionTypeService;
import com.yoho.search.dal.model.PromotionType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class PromotionTypeIndexBuilder extends IIndexBuilder {
@Autowired
private PromotionTypeService promotionTypeService;
@Override
public int getTotalCount() throws Exception {
return promotionTypeService.count();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
return promotionTypeService.getPageLists(offset,limit);
}
@Override
public String getId(Object object) {
return ((PromotionType) object).getId().toString();
}
}
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import java.util.List;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.PromotionIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.PromotionProductFlagsService;
import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
import com.yoho.search.dal.model.PromotionBO;
import com.yoho.search.dal.model.PromotionProductFlags;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@SearchMqConsumerListerner(tableName = "promotion_product_flags")
... ... @@ -36,7 +34,7 @@ public class PromotionProductFlagsMqListener extends AbstractMqListener {
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PROMOTION;
return ISearchConstants.INDEX_NAME_ZQ_NAME;
}
@Override
... ...
package com.yoho.search.consumer.index.increment.database;
package com.yoho.search.consumer.index.increment.otherIndex;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.PromotionTypeService;
import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
import com.yoho.search.dal.model.PromotionType;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -20,6 +20,8 @@ public class PromotionTypeMqListener extends AbstractMqListener {
@Autowired
private PromotionTypeService promotionTypeService;
@Autowired
private IYohoIndexService indexService;
@Override
protected EventReportEnum getEventReportEnum() {
... ... @@ -29,6 +31,7 @@ public class PromotionTypeMqListener extends AbstractMqListener {
@Override
protected void deleteData(String id) throws Exception {
promotionTypeService.delete(Integer.valueOf(id));
indexService.deleteIndexData(this.getIndexName(), id);
}
@Override
... ... @@ -37,6 +40,8 @@ public class PromotionTypeMqListener extends AbstractMqListener {
if (promotionType == null || promotionType.getId() == null) {
return;
}
String idValue = promotionType.getId().toString();
promotionTypeService.saveOrUpdate(promotionType);
indexService.updateIndexData(this.getIndexName(), idValue, promotionType);
}
}
... ...
... ... @@ -62,10 +62,10 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware {
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_PRICE_PLAN);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_HELPER);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_SHOPS);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PROMOTION);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_ZQ_NAME);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PROMOTIONTYPE);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_IMAGE_VECTORS);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_BIGDATESIMILARSKNINDEX);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_INDEX);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_BRAND);//依赖pi重建过后的向量
logger.info("indexRebuildJob execute end----[end={}][cost={}]", System.currentTimeMillis(), (System.currentTimeMillis() - begin));
... ...
index.analysis.analyzer.default.type: keyword
index.analysis.analyzer.default.type: keyword
\ No newline at end of file
... ...
index.analysis.analyzer.default.type: keyword
... ...
{
"promotiontype": {
"_all": {
"enabled": false
},
"_source": {
"enabled": true
},
"properties": {
"id": {
"type": "long"
},
"name": {
"type": "keyword"
},
"promotionType": {
"type": "keyword"
},
"info": {
"type": "keyword"
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -3,8 +3,8 @@
<client>
<name>yohoSearchElasticsearch</name>
<properties>
<property key="es.cluster.name" value="yohosearch-dev-5.4.3"/>
<property key="es.servers" value="192.168.102.12:9300 192.168.102.13:9300"/>
<property key="es.cluster.name" value="yohosearch_test"/>
<property key="es.servers" value="192.168.102.209:9300 192.168.102.216:9300"/>
</properties>
<index>
... ... @@ -192,7 +192,7 @@
</index>
<index>
<name>promotion</name>
<name>zqname</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_replicas" value="0"/>
... ... @@ -200,8 +200,8 @@
<property key="translog.flush_threshold_size" value="100mb"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.PromotionIndexBuilder</builderClass>
<mappingFile>esmapping/promotion.json</mappingFile>
<analysisFile>analysis/promotion.yml</analysisFile>
<mappingFile>esmapping/zqname.json</mappingFile>
<analysisFile>analysis/zqname.yml</analysisFile>
</index>
<index>
... ... @@ -257,5 +257,18 @@
<analysisFile>analysis/bigdatasimilarskn.yml</analysisFile>
</index>
<index>
<name>promotiontype</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_replicas" value="0"/>
<property key="refresh_interval" value="10s"/>
<property key="translog.flush_threshold_size" value="100mb"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.PromotionTypeIndexBuilder</builderClass>
<mappingFile>esmapping/promotiontype.json</mappingFile>
<analysisFile>analysis/promotiontype.yml</analysisFile>
</index>
</client>
</IndexConfigs>
\ No newline at end of file
... ...
... ... @@ -190,7 +190,7 @@
</index>
<index>
<name>promotion</name>
<name>zqname</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_replicas" value="${search.index.number_of_replicas}"/>
... ... @@ -198,8 +198,8 @@
<property key="translog.flush_threshold_size" value="${search.index.translog.flush_threshold_size}"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.PromotionIndexBuilder</builderClass>
<mappingFile>esmapping/promotion.json</mappingFile>
<analysisFile>analysis/promotion.yml</analysisFile>
<mappingFile>esmapping/zqname.json</mappingFile>
<analysisFile>analysis/zqname.yml</analysisFile>
</index>
<index>
... ... @@ -254,5 +254,18 @@
<analysisFile>analysis/bigdatasimilarskn.yml</analysisFile>
</index>
<index>
<name>promotiontype</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.PromotionTypeIndexBuilder</builderClass>
<mappingFile>esmapping/promotiontype.json</mappingFile>
<analysisFile>analysis/promotiontype.yml</analysisFile>
</index>
</client>
</IndexConfigs>
... ...