Skip to content

Commit

Permalink
!213 优化代码,修复自动生成的es分词无效问题
Browse files Browse the repository at this point in the history
Merge pull request !213 from OceansDeep/feature/pg
  • Loading branch information
OceansDeep authored and gitee-org committed Jul 21, 2022
2 parents 3236a05 + 4ec2c1b commit 12280e5
Show file tree
Hide file tree
Showing 8 changed files with 664 additions and 7 deletions.
651 changes: 651 additions & 0 deletions deploy-api.yml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SystemLogVO implements Serializable {

@ApiModelProperty(value = "日志记录时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@Field(type = FieldType.Date, format = DateFormat.basic_date_time)
@Field(type = FieldType.Date, format = DateFormat.basic_date_time, fielddata = true)
private Date createTime = new Date();

@ApiModelProperty(value = "请求用户")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class CustomWords extends BaseEntity {
private String name;


@ApiModelProperty(value = "是否禁用")
@ApiModelProperty(value = "是否禁用: 0,禁用;1,不禁用")
private Integer disabled;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cn.lili.modules.search.mapper;

import cn.lili.modules.search.entity.dos.CustomWords;
import cn.lili.mybatis.mybatisplus.SpiceBaseMapper;
import cn.lili.mybatis.mybatisplus.external.SpiceBaseMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public interface CustomWordsService extends IService<CustomWords> {
*/
boolean deleteBathByName(List<String> names);

/**
* 批量插入自定义分词
*
* @param customWordsList 自定义分词列表
* @return 受影响行数
*/
long insertBatchCustomWords(List<CustomWords> customWordsList);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,15 @@ private void analyzeAndSaveWords(EsGoodsIndex goods) {
for (EsGoodsAttribute esGoodsAttribute : goods.getAttrList()) {
if (keywordsList.stream().noneMatch(i -> i.toLowerCase(Locale.ROOT).equals(esGoodsAttribute.getValue().toLowerCase(Locale.ROOT)))) {
keywordsList.add(esGoodsAttribute.getValue());
customWordsList.add(new CustomWords(esGoodsAttribute.getValue(), 0));
customWordsList.add(new CustomWords(esGoodsAttribute.getValue(), 1));
}
}
}
//分析词条
for (AnalyzeResponse.AnalyzeToken token : tokens) {
if (keywordsList.stream().noneMatch(i -> i.toLowerCase(Locale.ROOT).equals(token.getTerm().toLowerCase(Locale.ROOT)))) {
keywordsList.add(token.getTerm());
customWordsList.add(new CustomWords(token.getTerm(), 0));
customWordsList.add(new CustomWords(token.getTerm(), 1));
}
//保存词条进入数据库
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.lili.mybatis.mybatisplus;
package cn.lili.mybatis.mybatisplus.external;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.lili.mybatis.mybatisplus;
package cn.lili.mybatis.mybatisplus.external;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
Expand Down

0 comments on commit 12280e5

Please sign in to comment.