"reason":"failed to parse date field
"type":"date_time_parse_exception"
problem
spring boot 에서
spring data Elasticsearch 를 사용중에 엔티티를 ES 로 보내는 과정에서 Date 타입이 바뀌었다.

{"error":{"root_cause":[{"type":"document_parsing_exception","reason":"[1:212] failed to parse field [createdAt] of type [date] in document with id 'Hs_n85gB5cX2woQzknEm'. Preview of field's value: '2025-08-29'"}],"type":"document_parsing_exception","reason":"[1:212] failed to parse field [createdAt] of type [date] in document with id 'Hs_n85gB5cX2woQzknEm'. Preview of field's value: '2025-08-29'","caused_by":{"type":"illegal_argument_exception","reason":"failed to parse date field [2025-08-29] with format [yyyy-MM-dd'T'HH:mm:ss]","caused_by":{"type":"date_time_parse_exception","reason":"Text '2025-08-29' could not be parsed at index 10"}}},"status":400}
solution
data class Entity(
.
.
.
// 변경 전
@Field(type = FieldType.Date,)
val createdAt: LocalDateTime,
// 변경 후
@Field(
type = FieldType.Date,
format = [DateFormat.date_hour_minute_second],
pattern = ["yyyy-MM-dd'T'HH:mm||yyyy-MM-dd'T'HH:mm:ss||strict_date_optional_time"]
)
val createdAt: LocalDateTime,
포맷 타입을 지정 해주었더니 잘 들어감 !
'일-상 > 오류노트' 카테고리의 다른 글
| [오류노트] expo eas versionCode 안올라감 ㅜ (0) | 2025.09.03 |
|---|---|
| [오류노트] React native FAILED: build.ninja (0) | 2025.09.02 |
| [오류노트] expo-iap 'AppTransaction' has no member 'appTransactionID' (0) | 2025.08.29 |
| [오류노트] android 실제 기기에서 이미지 안뜸 (feat.Naver Map) (4) | 2025.08.15 |
| [오류노트] ServletRequest 캐싱이 낳은 h2 로그인 에러 (1) | 2025.07.01 |