修复生成索引时no such index问题

This commit is contained in:
paulGao 2022-06-17 11:20:22 +08:00
parent 2e4c6f4284
commit d704e2eb55
5 changed files with 14 additions and 15 deletions

View File

@ -85,7 +85,6 @@ public abstract class BaseElasticsearchService {
*/
protected void createIndexRequest(String index) {
try {
deleteIndexRequest(index);
CreateIndexRequest request = new CreateIndexRequest(index);
//Settings for this index
request.settings(Settings.builder()

View File

@ -143,7 +143,8 @@ public interface GoodsSkuService extends IService<GoodsSku> {
/**
* 分页查询商品sku信息
*
* @param searchParams 查询参数
* @param page 分页参数
* @param queryWrapper 查询参数
* @return 商品sku信息
*/
IPage<GoodsSkuDTO> getGoodsSkuDTOByPage(Page<GoodsSkuDTO> page, Wrapper<GoodsSkuDTO> queryWrapper);

View File

@ -17,7 +17,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@ -85,15 +84,13 @@ public class FootprintServiceImpl extends ServiceImpl<FootprintMapper, FootPrint
//定义结果
IPage<EsGoodsIndex> esGoodsIndexIPage = new Page<EsGoodsIndex>();
IPage<EsGoodsIndex> esGoodsIndexIPage = new Page<>();
if (footPrintPages.getRecords() == null || footPrintPages.getRecords().isEmpty()) {
return esGoodsIndexIPage;
} else {
List<EsGoodsIndex> list = esGoodsSearchService.getEsGoodsBySkuIds(
footPrintPages.getRecords().stream().map(item -> {
return item.getSkuId();
}).collect(Collectors.toList()));
footPrintPages.getRecords().stream().map(FootPrint::getSkuId).collect(Collectors.toList()));
//去除为空的商品数据
list.removeIf(Objects::isNull);

View File

@ -1,5 +1,6 @@
package cn.lili.modules.payment.kit.params.dto;
import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.utils.StringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -18,7 +19,7 @@ import java.util.List;
@ToString
public class CashierParam {
static Long MAX_DETAIL_LENGTH = 30L;
static final Long MAX_DETAIL_LENGTH = 30L;
@ApiModelProperty(value = "价格")
private Double price;
@ -46,7 +47,7 @@ public class CashierParam {
private Double walletValue;
public String getDetail() {
if (StringUtils.isEmpty(detail)) {
if (CharSequenceUtil.isEmpty(detail)) {
return "清单详细";
}
return StringUtils.filterSpecialChart(StringUtils.sub(detail, 30));

View File

@ -86,9 +86,9 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
private final Map<String, Field> fieldMap = ReflectUtil.getFieldMap(EsGoodsIndex.class);
private final String KEY_SUCCESS = "success";
private final String KEY_FAIL = "fail";
private final String KEY_PROCESSED = "processed";
private static final String KEY_SUCCESS = "success";
private static final String KEY_FAIL = "fail";
private static final String KEY_PROCESSED = "processed";
@Autowired
private ElasticsearchProperties elasticsearchProperties;
@ -105,8 +105,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
@Autowired
private GoodsSkuService goodsSkuService;
@Autowired
private GoodsService goodsService;
@Autowired
private BrandService brandService;
@Autowired
@ -425,8 +423,11 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
//如果索引存在则删除重新生成 这里应该有更优解
boolean indexExist = this.indexExist(indexName);
if (regeneratorIndex || !indexExist) {
if (indexExist) {
this.deleteIndexRequest(indexName);
}
//如果索引不存在则创建索引
createIndexRequest(indexName);
this.createIndexRequest(indexName);
}
Map<String, Long> resultMap = (Map<String, Long>) cache.get(CachePrefix.INIT_INDEX_PROCESS.getPrefix());