修复一个搜索es商品时可能会发生的date格式转换问题
This commit is contained in:
parent
6d014a01bc
commit
74b0a5b081
@ -165,14 +165,8 @@ public abstract class BaseElasticsearchService {
|
||||
" \"type\": \"long\"\n" +
|
||||
" },\n" +
|
||||
" \"releaseTime\": {\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"fielddata\": true, \n" +
|
||||
" \"fields\": {\n" +
|
||||
" \"keyword\": {\n" +
|
||||
" \"type\": \"keyword\",\n" +
|
||||
" \"ignore_above\": 256\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" \"type\": \"date\",\n" +
|
||||
" \"format\": \"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis\"\n" +
|
||||
" },\n" +
|
||||
" \"categoryPath\": {\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
|
@ -6,14 +6,12 @@ import cn.lili.elasticsearch.EsSuffix;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
|
||||
import cn.lili.modules.promotion.tools.PromotionTools;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.elasticsearch.annotations.DateFormat;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
@ -251,9 +249,8 @@ public class EsGoodsIndex implements Serializable {
|
||||
private String goodsVideo;
|
||||
|
||||
@ApiModelProperty("商品发布时间")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Field(type = FieldType.Date, format = DateFormat.basic_date_time)
|
||||
private Date releaseTime;
|
||||
@Field(type = FieldType.Date)
|
||||
private Long releaseTime;
|
||||
|
||||
/**
|
||||
* @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum
|
||||
@ -309,7 +306,7 @@ public class EsGoodsIndex implements Serializable {
|
||||
this.grade = sku.getGrade();
|
||||
this.recommend = sku.getRecommend();
|
||||
this.goodsType = sku.getGoodsType();
|
||||
this.releaseTime = new Date();
|
||||
this.releaseTime = new Date().getTime();
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,7 +371,7 @@ public class EsGoodsIndex implements Serializable {
|
||||
this.authFlag = sku.getAuthFlag();
|
||||
this.intro = sku.getIntro();
|
||||
this.grade = sku.getGrade();
|
||||
this.releaseTime = new Date();
|
||||
this.releaseTime = new Date().getTime();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
UpdateRequest updateRequest = new UpdateRequest(indexName, goodsIndex.getId());
|
||||
|
||||
JSONObject jsonObject = JSONUtil.parseObj(goodsIndex);
|
||||
jsonObject.set("releaseTime", goodsIndex.getReleaseTime().getTime());
|
||||
jsonObject.set("releaseTime", goodsIndex.getReleaseTime());
|
||||
updateRequest.doc(jsonObject);
|
||||
request.add(updateRequest);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user