failed to parse date field [2021-04-19T16:35:04.000Z] with format [yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis||yyyy-MM-dd'T'HH:mm:ss]],自己使用springboot来整合es,但是现在在日期这里有点问题????
package com.jd.wego.entity;
import lombok.Data;
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;
import java.util.Date;
/**
* @author hbquan
* @date 2021/4/6 14:39
*/
@Data
@Document(indexName = "wego", type = "_doc", createIndex = false)
public class Article {
@Id
@Field(name = "article_id")
private int articleId;
@Field(type = FieldType.Text, analyzer = "ik_max_word", name = "article_title")
private String articleTitle;
@Field(type = FieldType.Text, name = "article_summary")
private String articleSummary;
@Field(type = FieldType.Text, analyzer = "ik_max_word", name = "article_context")
private String articleContent;
@Field(type = FieldType.Integer, name = "article_view_count")
private int articleViewCount;
@Field(type = FieldType.Integer, name = "article_like_count")
private int articleLikeCount;
@Field(type = FieldType.Integer, name = "article_comment_count")
private int articleCommentCount;
@Field(type = FieldType.Date, name = "created_time", format = DateFormat.custom,
pattern = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis||yyyy-MM-dd'T'HH:mm:ss")
private Date createdTime;
@Field(type = FieldType.Date, name = "update_time", format = DateFormat.custom,
pattern = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis||yyyy-MM-dd'T'HH:mm:ss")
private Date updateTime;
/**
* isDelete表示两种状态,0表示未删除,1表示已删除
*/
@Field(type = FieldType.Integer, name = "is_deleted")
private int isDeleted;
@Field(type = FieldType.Integer, name = "article_category_id")
private int articleCategoryId;
@Field(type = FieldType.Text, name = "article_user_id")
private String articleUserId;
}这是ES中的查出的数据:
{
"took" : 1307,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "wego",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"article_summary" : "study hard",
"article_view_count" : 1,
"article_user_id" : "18392710807",
"created_time" : "2021-04-14T21:16:42.000Z",
"article_like_count" : 1,
"@timestamp" : "2021-04-20T08:00:00.914Z",
"is_deleted" : false,
"article_comment_count" : 1,
"article_category_id" : 1,
"update_time" : "2021-04-14T21:16:46.000Z",
"article_title" : "how to join Google",
"article_content" : """
1)如果你的员工就像在《软件公司的两种管理》中所说的,像Widget Factories那样,净是些X型的人的话,那么,你也只有使用加班和加人这种方式,就像长城和金字塔的建设过程一样,就像富士康一样,你的团队本质是不会思考只能用鞭子去抽他们的方式去管理。于是,你也只能用“狼性”来呼唤你的员工像那些低智商的野兽一样的行事。
2)有时候,我们需要去“卡位”,需要很快地去实现一个东西占领市场,这需要加班。就像Win95和Intel的奔腾芯片的浮点数问题一样。但是千万不要忘了,你在卡完位后,得马上把你产品的质量搞上去,不然,你一样会死得很难看。(Windows是有两个团队的,一个团队是用来占领市场的,另一个团队是安心搞发展的)注意:“卡位”从某种程度上来说应该是一种有价值的事,但我们依然要思考是否在用蛮力行事。
3)另外,有的人工作就是生活,生活就是工作,所以,对他来说,这不是一种工作,而是一种事业。我认可这样的精神和热情,但是,我还是想让这样的人反思一下自己,有没有用一种更为聪明的方式来从事自己的事业?而不是用蛮力。
""",
"@version" : "1",
"article_id" : 1
}
},
{
"_index" : "wego",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"article_summary" : null,
"article_view_count" : 0,
"article_user_id" : "18392710807",
"created_time" : "2021-04-19T16:35:04.000Z",
"article_like_count" : 0,
"@timestamp" : "2021-04-20T08:00:00.915Z",
"is_deleted" : false,
"article_comment_count" : 0,
"article_category_id" : 1,
"update_time" : "2021-04-19T16:35:06.000Z",
"article_title" : "有人认识王欣吗",
"article_content" : "求王欣的联系方式??",
"@version" : "1",
"article_id" : 2
}
}
]
}
}