Authored by saihide

add table

Showing 21 changed files with 630 additions and 0 deletions
package com.yoho.search.dal;
import com.yoho.search.dal.model.BigdataBrandVector;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface BigdataBrandVectorMapper {
int selectCount();
List<BigdataBrandVector> selectPageLists(@Param(value="start")Integer start, @Param(value="limit")Integer limit);
}
... ...
package com.yoho.search.dal;
import com.yoho.search.dal.model.BigdataBrandVectorW2v;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface BigdataBrandVectorMapperW2v {
int selectCount();
List<BigdataBrandVectorW2v> selectPageLists(@Param(value="start")Integer start, @Param(value="limit")Integer limit);
}
... ...
package com.yoho.search.dal;
import com.yoho.search.dal.model.BigdataSortBrandVectorW2v;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface BigdataSortBrandVectorW2vMapper {
int selectCount();
List<BigdataSortBrandVectorW2v> selectPageLists(@Param(value="start")Integer start, @Param(value="limit")Integer limit);
}
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.search.dal.BigdataBrandVectorMapper">
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.BigdataBrandVector">
<id column="brand_id" property="brandId" jdbcType="INTEGER"/>
<result column="vector" property="vector" jdbcType="VARCHAR"/>
<result column="update_time" property="updateTime" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
brand_id, vector, update_time
</sql>
<select id="selectCount" resultType="int">
select count(0) from bigdata_brand_vector
</select>
<select id="selectPageLists" resultMap="BaseResultMap" timeout="20000">
select <include refid="Base_Column_List" /> from bigdata_brand_vector limit #{start}, #{limit}
</select>
</mapper>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.search.dal.BigdataBrandVectorMapperW2v">
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.BigdataBrandVectorW2v">
<id column="brand_id" property="brandId" jdbcType="INTEGER"/>
<result column="vector" property="vector" jdbcType="VARCHAR"/>
<result column="update_time" property="updateTime" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
brand_id, vector, update_time
</sql>
<select id="selectCount" resultType="int">
select count(0) from bigdata_brand_vector_w2v
</select>
<select id="selectPageLists" resultMap="BaseResultMap" timeout="20000">
select <include refid="Base_Column_List" /> from bigdata_brand_vector_w2v limit #{start}, #{limit}
</select>
</mapper>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.search.dal.BigdataSortBrandVectorW2vMapper">
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.BigdataSortBrandVectorW2v">
<id column="brand_id" property="brandId" jdbcType="INTEGER"/>
<id column="middle_sort_id" property="middleSortId" jdbcType="INTEGER"/>
<result column="vector" property="vector" jdbcType="VARCHAR"/>
<result column="update_time" property="updateTime" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
brand_id, middle_sort_id, vector, update_time
</sql>
<select id="selectCount" resultType="int">
select count(0) from bigdata_sort_brand_vector_w2v
</select>
<select id="selectPageLists" resultMap="BaseResultMap" timeout="20000">
select <include refid="Base_Column_List" /> from bigdata_sort_brand_vector_w2v limit #{start}, #{limit}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.search.consumer.index.fullbuild;
import com.yoho.search.consumer.index.common.IIndexBuilder;
import com.yoho.search.consumer.service.bo.BigdataBrandVectorBO;
import com.yoho.search.dal.BigdataBrandVectorMapper;
import com.yoho.search.dal.model.BigdataBrandVector;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Component
public class BigdataBrandVectorIndexBuilder extends IIndexBuilder {
@Autowired
private BigdataBrandVectorMapper bigdataBrandVectorMapper;
@Override
public int getTotalCount() throws Exception {
return bigdataBrandVectorMapper.selectCount();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
List<BigdataBrandVector> vectorList = bigdataBrandVectorMapper.selectPageLists(offset, limit);
if (CollectionUtils.isEmpty(vectorList)) {
return Collections.emptyList();
}
List<BigdataBrandVectorBO> vectorBOS = new ArrayList<>();
for (BigdataBrandVector vector : vectorList) {
if (vector.getBrandId() == null) {
continue;
}
vectorBOS.add(getBigdataBrandVectorBO(vector));
}
return vectorBOS;
}
@Override
public String getId(Object object) {
return ((BigdataBrandVectorBO) object).getId().toString();
}
public BigdataBrandVectorBO getBigdataBrandVectorBO(BigdataBrandVector vector) {
BigdataBrandVectorBO vectorBO = new BigdataBrandVectorBO();
vectorBO.setId(vector.getBrandId().longValue());
vectorBO.setBrandId(vector.getBrandId());
vectorBO.setVector(vector.getVector());
vectorBO.setUpdateTime(vector.getUpdateTime());
return vectorBO;
}
}
... ...
package com.yoho.search.consumer.index.fullbuild;
import com.yoho.search.consumer.index.common.IIndexBuilder;
import com.yoho.search.consumer.service.bo.BigdataBrandVectorBO;
import com.yoho.search.dal.BigdataBrandVectorMapperW2v;
import com.yoho.search.dal.model.BigdataBrandVectorW2v;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Component
public class BigdataBrandVectorW2vIndexBuilder extends IIndexBuilder {
@Autowired
private BigdataBrandVectorMapperW2v bigdataBrandVectorMapperW2v;
@Override
public int getTotalCount() throws Exception {
return bigdataBrandVectorMapperW2v.selectCount();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
List<BigdataBrandVectorW2v> vectorList = bigdataBrandVectorMapperW2v.selectPageLists(offset, limit);
if (CollectionUtils.isEmpty(vectorList)) {
return Collections.emptyList();
}
List<BigdataBrandVectorBO> vectorBOS = new ArrayList<>();
for (BigdataBrandVectorW2v vector : vectorList) {
if (vector.getBrandId() == null) {
continue;
}
vectorBOS.add(getBigdataBrandVectorBO(vector));
}
return vectorBOS;
}
@Override
public String getId(Object object) {
return ((BigdataBrandVectorBO) object).getId().toString();
}
public BigdataBrandVectorBO getBigdataBrandVectorBO(BigdataBrandVectorW2v vector) {
BigdataBrandVectorBO vectorBO = new BigdataBrandVectorBO();
vectorBO.setId(vector.getBrandId().longValue());
vectorBO.setBrandId(vector.getBrandId());
vectorBO.setVector(vector.getVector());
vectorBO.setUpdateTime(vector.getUpdateTime());
return vectorBO;
}
}
... ...
package com.yoho.search.consumer.index.fullbuild;
import com.yoho.search.consumer.index.common.IIndexBuilder;
import com.yoho.search.consumer.service.bo.BigdataSortBrandVectorBO;
import com.yoho.search.dal.BigdataSortBrandVectorW2vMapper;
import com.yoho.search.dal.model.BigdataSortBrandVectorW2v;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Component
public class BigdataSortBrandVectorW2vIndexBuilder extends IIndexBuilder {
@Autowired
private BigdataSortBrandVectorW2vMapper bigdataSortBrandVectorW2vMapper;
@Override
public int getTotalCount() throws Exception {
return bigdataSortBrandVectorW2vMapper.selectCount();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
List<BigdataSortBrandVectorW2v> vectorList = bigdataSortBrandVectorW2vMapper.selectPageLists(offset, limit);
if (CollectionUtils.isEmpty(vectorList)) {
return Collections.emptyList();
}
List<BigdataSortBrandVectorBO> vectorBOS = new ArrayList<>();
for (BigdataSortBrandVectorW2v vector : vectorList) {
if (vector.getBrandId() == null || vector.getMiddleSortId() == null) {
continue;
}
vectorBOS.add(getBigdataSortBrandVectorBO(vector));
}
return vectorBOS;
}
@Override
public String getId(Object object) {
return ((BigdataSortBrandVectorBO) object).getId();
}
public BigdataSortBrandVectorBO getBigdataSortBrandVectorBO(BigdataSortBrandVectorW2v vector) {
BigdataSortBrandVectorBO vectorBO = new BigdataSortBrandVectorBO();
vectorBO.setId(vector.getBrandId() + "_" + vector.getMiddleSortId());
vectorBO.setBrandId(vector.getBrandId());
vectorBO.setMiddleSortId(vector.getMiddleSortId());
vectorBO.setVector(vector.getVector());
vectorBO.setUpdateTime(vector.getUpdateTime());
return vectorBO;
}
}
... ...
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.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.BigdataBrandVectorIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.bo.BigdataBrandVectorBO;
import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
import com.yoho.search.dal.model.BigdataBrandVector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@SearchMqConsumerListerner(tableName = "bigdata_brand_vector")
public class BigdataBrandVectorMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(BigdataBrandVectorMqListener.class);
@Autowired
private IYohoIndexService indexService;
@Autowired
private BigdataBrandVectorIndexBuilder bigdataBrandVectorIndexBuilder;
@Override
protected String getIndexName() {
return ISearchConstants.INDEX_NAME_BIGDATABRANDVECTOR;
}
@Override
protected EventReportEnum getEventReportEnum() {
return EventReportEnum.BIGDATABRANDVECTORMQLISTENER_ONMESSAGE;
}
@Override
protected void deleteData(String id) throws Exception {
indexService.deleteIndexData(ISearchConstants.INDEX_NAME_BIGDATABRANDVECTOR, id);
}
@Override
protected void updateData(JSONObject data) throws Exception {
BigdataBrandVector vector = ConvertUtils.toJavaObject(BigdataBrandVector.class, data);
if (vector != null && vector.getBrandId() != null) {
BigdataBrandVectorBO vectorBO = bigdataBrandVectorIndexBuilder.getBigdataBrandVectorBO(vector);
indexService.updateIndexData(ISearchConstants.INDEX_NAME_BIGDATABRANDVECTOR, vectorBO.getId().toString(), vectorBO);
}
}
}
... ...
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.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.BigdataBrandVectorW2vIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.bo.BigdataBrandVectorBO;
import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
import com.yoho.search.dal.model.BigdataBrandVectorW2v;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@SearchMqConsumerListerner(tableName = "bigdata_brand_vector_w2v")
public class BigdataBrandVectorW2vMqListener extends AbstractMqListener {
@Autowired
private IYohoIndexService indexService;
@Autowired
private BigdataBrandVectorW2vIndexBuilder bigdataBrandVectorW2vIndexBuilder;
@Override
protected String getIndexName() {
return ISearchConstants.INDEX_NAME_BIGDATABRANDVECTORW2V;
}
@Override
protected EventReportEnum getEventReportEnum() {
return EventReportEnum.BIGDATABRANDVECTORW2VMQLISTENER_ONMESSAGE;
}
@Override
protected void deleteData(String id) throws Exception {
indexService.deleteIndexData(ISearchConstants.INDEX_NAME_BIGDATABRANDVECTORW2V, id);
}
@Override
protected void updateData(JSONObject data) throws Exception {
BigdataBrandVectorW2v vector = ConvertUtils.toJavaObject(BigdataBrandVectorW2v.class, data);
if (vector != null && vector.getBrandId() != null) {
BigdataBrandVectorBO vectorBO = bigdataBrandVectorW2vIndexBuilder.getBigdataBrandVectorBO(vector);
indexService.updateIndexData(ISearchConstants.INDEX_NAME_BIGDATABRANDVECTORW2V, vectorBO.getId().toString(), vectorBO);
}
}
}
... ...
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.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.BigdataSortBrandVectorW2vIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.bo.BigdataSortBrandVectorBO;
import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
import com.yoho.search.dal.model.BigdataSortBrandVectorW2v;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@SearchMqConsumerListerner(tableName = "bigdata_sort_brand_vector_w2v")
public class BigdataSortBrandVectorW2vMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(BigdataSortBrandVectorW2vMqListener.class);
@Autowired
private IYohoIndexService indexService;
@Autowired
private BigdataSortBrandVectorW2vIndexBuilder bigdataSortBrandVectorW2vIndexBuilder;
@Override
protected String getIndexName() {
return ISearchConstants.INDEX_NAME_BIGDATASORTBRANDVECTORW2V;
}
@Override
protected EventReportEnum getEventReportEnum() {
return EventReportEnum.BIGDATASORTBRANDVECTORW2VMQLISTENER_ONMESSAGE;
}
@Override
protected void deleteData(String id) throws Exception {
logger.error("[func=deleteData by id ][id={}]", id);
}
@Override
protected void deleteDataByObject(final JSONObject data) throws Exception {
BigdataSortBrandVectorW2v bigdataSortBrandVector = ConvertUtils.toJavaObject(BigdataSortBrandVectorW2v.class, data);
if (bigdataSortBrandVector != null && bigdataSortBrandVector.getBrandId() != null && bigdataSortBrandVector.getMiddleSortId() != null) {
String indexId = bigdataSortBrandVector.getBrandId() + "_" + bigdataSortBrandVector.getMiddleSortId();
indexService.deleteIndexData(ISearchConstants.INDEX_NAME_BIGDATASORTBRANDVECTORW2V, indexId);
}
}
@Override
protected void updateData(JSONObject data) throws Exception {
BigdataSortBrandVectorW2v vector = ConvertUtils.toJavaObject(BigdataSortBrandVectorW2v.class, data);
if (vector != null && vector.getBrandId() != null && vector.getMiddleSortId() != null) {
BigdataSortBrandVectorBO vectorBO = bigdataSortBrandVectorW2vIndexBuilder.getBigdataSortBrandVectorBO(vector);
indexService.updateIndexData(ISearchConstants.INDEX_NAME_BIGDATASORTBRANDVECTORW2V, vectorBO.getId(), vectorBO);
}
}
}
... ...
index.analysis.analyzer.default.type: keyword
\ No newline at end of file
... ...
index.analysis.analyzer.default.type: keyword
\ No newline at end of file
... ...
index.analysis.analyzer.default.type: keyword
\ No newline at end of file
... ...
{
"bigdatabrandvector": {
"_all":{
"enabled":false
},
"_source":{
"enabled":true
},
"properties": {
"id": {
"type": "long"
},
"brandId": {
"type": "integer"
},
"vector": {
"type": "keyword"
},
"updateTime": {
"type": "text"
}
}
}
}
\ No newline at end of file
... ...
{
"bigdatabrandvectorw2v": {
"_all":{
"enabled":false
},
"_source":{
"enabled":true
},
"properties": {
"id": {
"type": "long"
},
"brandId": {
"type": "integer"
},
"vector": {
"type": "keyword"
},
"updateTime": {
"type": "text"
}
}
}
}
\ No newline at end of file
... ...
{
"bigdatasortbrandvectorw2v": {
"_all":{
"enabled":false
},
"_source":{
"enabled":true
},
"properties": {
"id": {
"type": "keyword"
},
"brandId": {
"type": "integer"
},
"middleSortId": {
"type": "integer"
},
"vector": {
"type": "keyword"
},
"updateTime": {
"type": "text"
}
}
}
}
\ No newline at end of file
... ...
package com.yoho.search.consumer.service.bo;
public class BigdataBrandVectorBO {
private Long id;
private Integer brandId;
private String vector;
private Integer updateTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getBrandId() {
return brandId;
}
public void setBrandId(Integer brandId) {
this.brandId = brandId;
}
public String getVector() {
return vector;
}
public void setVector(String vector) {
this.vector = vector;
}
public Integer getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
}
... ...
... ... @@ -296,5 +296,44 @@
<analysisFile>analysis/bigdatasortbrandvector.yml</analysisFile>
</index>
<index>
<name>bigdatasortbrandvectorw2v</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.BigdataSortBrandVectorW2vIndexBuilder</builderClass>
<mappingFile>esmapping/bigdatasortbrandvectorw2v.json</mappingFile>
<analysisFile>analysis/bigdatasortbrandvectorw2v.yml</analysisFile>
</index>
<index>
<name>bigdatabrandvector</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.BigdataBrandVectorIndexBuilder</builderClass>
<mappingFile>esmapping/bigdatabrandvector.json</mappingFile>
<analysisFile>analysis/bigdatabrandvector.yml</analysisFile>
</index>
<index>
<name>bigdatabrandvectorw2v</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.BigdataBrandVectorW2vIndexBuilder</builderClass>
<mappingFile>esmapping/bigdatabrandvectorw2v.json</mappingFile>
<analysisFile>analysis/bigdatabrandvectorw2v.yml</analysisFile>
</index>
</client>
</IndexConfigs>
\ No newline at end of file
... ...
... ... @@ -295,5 +295,44 @@
<analysisFile>analysis/bigdatasortbrandvector.yml</analysisFile>
</index>
<index>
<name>bigdatasortbrandvectorw2v</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.BigdataSortBrandVectorW2vIndexBuilder</builderClass>
<mappingFile>esmapping/bigdatasortbrandvectorw2v.json</mappingFile>
<analysisFile>analysis/bigdatasortbrandvectorw2v.yml</analysisFile>
</index>
<index>
<name>bigdatabrandvector</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.BigdataBrandVectorIndexBuilder</builderClass>
<mappingFile>esmapping/bigdatabrandvector.json</mappingFile>
<analysisFile>analysis/bigdatabrandvector.yml</analysisFile>
</index>
<index>
<name>bigdatabrandvectorw2v</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.BigdataBrandVectorW2vIndexBuilder</builderClass>
<mappingFile>esmapping/bigdatabrandvectorw2v.json</mappingFile>
<analysisFile>analysis/bigdatabrandvectorw2v.yml</analysisFile>
</index>
</client>
</IndexConfigs>
... ...