Authored by Gino Zhang

增加conversion索引

package com.yoho.search.consumer.index.fullbuild;
import com.yoho.search.consumer.index.common.IIndexBuilder;
import com.yoho.search.consumer.service.base.SuggestConversionService;
import com.yoho.search.consumer.service.bo.ConversionBO;
import com.yoho.search.dal.model.SuggestConversion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
public class SuggestConversionIndexBuilder extends IIndexBuilder {
@Autowired
private SuggestConversionService suggestConversionService;
@Override
public int getTotalCount() throws Exception {
return suggestConversionService.selectTotalCount();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
// 获取分页列表
List<SuggestConversion> list = suggestConversionService.selectPageList(offset, limit);
// 构建结果
List<ConversionBO> results = new ArrayList<>();
for (SuggestConversion item : list) {
results.add(new ConversionBO(item.getId(), item.getSource(), item.getDest()));
}
return results;
}
@Override
public String getId(Object object) {
return ((ConversionBO) object).getId().toString();
}
}
... ...
... ... @@ -37,6 +37,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware {
public void execute() {
long begin = System.currentTimeMillis();
logger.info("indexRebuildJob execute start----[begin={}]", begin);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CONVERSION);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_BRAND);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_SIZE);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_COLOR);
... ...
{
"conversion": {
"_all": {
"enabled": false
},
"_source": {
"enabled": true
},
"properties": {
"source": {
"type": "string",
"index": "ik_complex",
"search_analyzer": "ik_complex"
},
"dest": {
"type": "string",
"index": "ik_complex",
"search_analyzer": "ik_complex"
}
}
}
}
\ No newline at end of file
... ...
package com.yoho.search.consumer.service.bo;
import java.io.Serializable;
public class ConversionBO implements Serializable {
private static final long serialVersionUID = 7154651415633074270L;
private Integer id;
private String source;
private String dest;
public ConversionBO(){}
public ConversionBO(Integer id, String source, String dest){
this.id = id;
this.source = source;
this.dest = dest;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getDest() {
return dest;
}
public void setDest(String dest) {
this.dest = dest;
}
}
... ...
... ... @@ -92,6 +92,18 @@
</index>
<index>
<name>conversion</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_replicas" value="1"/>
<property key="refresh_interval" value="1s"/>
<property key="translog.flush_threshold_ops" value="5000"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.SuggestConversionIndexBuilder</builderClass>
<mappingFile>esmapping/conversion.json</mappingFile>
</index>
<index>
<name>tblproduct</name>
<properties>
<property key="number_of_shards" value="1"/>
... ...
... ... @@ -92,6 +92,18 @@
</index>
<index>
<name>conversion</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_ops" value="${search.index.translog.flush_threshold_ops}"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.SuggestConversionIndexBuilder</builderClass>
<mappingFile>esmapping/conversion.json</mappingFile>
</index>
<index>
<name>tblproduct</name>
<properties>
<property key="number_of_shards" value="1"/>
... ...