Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
245 views
in Technique[技术] by (71.8m points)

c# - Error when idexing document in elastic search

I get this error from elastc:

failed to parse date field [2020-12-30T23:00:00Z] with format [yyyy-MM-dd'T'HH:mm:ssZ] CausedBy: Type: date_time_parse_exception Reason: Text '2020-12-30T23:00:00Z' could not be parsed at index 19

Works on my machine but not when I deploy to customer system

To me the format and the value look like they should match. In the mapping I define the format:

.Date(s => s.Name(n => n.AsDate).Format("yyyy-MM-dd'T'HH:mm:ssZ"))

Any idea what could be causing this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It looks like it thinks Z is a formatter. Wrap it in single quotes like you did the T.

.Date(s => s.Name(n => n.AsDate).Format("yyyy-MM-dd'T'HH:mm:ss'Z'"))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...