Authored by wangnan9279

add tblbrand index

package com.yoho.search.consumer.index.fullbuild.tbl;
import com.yoho.search.consumer.index.fullbuild.IIndexBuilder;
import com.yoho.search.dal.TblBrandMapper;
import com.yoho.search.dal.model.TblBrand;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* 全球购品牌索引
*
* @author wangnan
* @version 2018/11/13
*/
@Component
public class TblBrandIndexBuilder extends IIndexBuilder {
@Autowired
private TblBrandMapper tblBrandMapper;
@Override
public int getTotalCount() throws Exception {
return tblBrandMapper.selectCount();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
List<TblBrand> tblBrandList = tblBrandMapper.selectBrandPageList(offset, limit);
if (CollectionUtils.isEmpty(tblBrandList)) {
return new ArrayList<>(0);
}
return tblBrandList;
}
@Override
public String getId(Object object) {
return ((TblBrand) object).getBrandId().toString();
}
}
... ...
... ... @@ -47,7 +47,7 @@ public class TblBrandMqListener extends AbstractMqListener {
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_BRAND;
return ISearchConstants.INDEX_NAME_TBL_BRAND;
}
@Override
... ... @@ -76,7 +76,9 @@ public class TblBrandMqListener extends AbstractMqListener {
}
//update DB
tblBrandService.saveOrUpdate(tblBrand);
//update ES:productIndex、tbl
//update TblBrand index
indexService.updateIndexData(this.getIndexName(), tblBrand.getBrandId().toString(), tblBrand);
//update ProductIndex、tblProduct index
List<Integer> sknList = tblProductService.getSknsByBrandId(tblBrand.getBrandId());
if (CollectionUtils.isEmpty(sknList)) {
return;
... ... @@ -92,6 +94,4 @@ public class TblBrandMqListener extends AbstractMqListener {
basicDataCacheService.clearTblBrand();
brandRelationUtils.buildBrandRelation();
}
}
... ...
index:
analysis:
tokenizer:
simple_pinyin:
type: pinyin
first_letter: none
padding_char: ''
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]+"
lowercase_standard:
tokenizer: standard
type: custom
filter:
- lowercase
- trim
- unique
pinyin_analyzer:
type: custom
tokenizer: simple_pinyin
filter:
- standard
- word_delimiter
- lowercase
- trim
- unique
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
... ...
{
"tblbrand": {
"_all": {
"enabled": false
},
"_source": {
"enabled": true
},
"properties": {
"brandId": {
"type": "integer"
},
"brandNameEn": {
"type": "keyword"
},
"brandNameCn": {
"type": "keyword"
},
"logo": {
"type": "keyword"
},
"star": {
"type": "keyword"
},
"siteIds": {
"type": "keyword"
},
"status": {
"type": "keyword"
},
"hot": {
"type": "keyword"
},
"isHide": {
"type": "integer"
},
"yohoBrandId": {
"type": "integer"
},
"createTime": {
"type": "integer"
},
"updateTime": {
"type": "integer"
},
"info": {
"type": "keyword"
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -136,6 +136,20 @@
</index>
<index>
<name>tblbrand</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.TblBrandIndexBuilder</builderClass>
<mappingFile>esmapping/tblbrand.json</mappingFile>
<analysisFile>analysis/tblbrand.yml</analysisFile>
<rebuildPageSize>2500</rebuildPageSize>
</index>
<index>
<name>standard</name>
<properties>
<property key="number_of_shards" value="1"/>
... ...
... ... @@ -134,6 +134,20 @@
</index>
<index>
<name>tblbrand</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.TblBrandIndexBuilder</builderClass>
<mappingFile>esmapping/tblbrand.json</mappingFile>
<analysisFile>analysis/tblbrand.yml</analysisFile>
<rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
</index>
<index>
<name>standard</name>
<properties>
<property key="number_of_shards" value="1"/>
... ...