【发布时间】:2021-09-16 14:31:09
【问题描述】:
首先,存储在索引中的日期格式是2021-09-16T14:06:02.000000Z
当我使用remember 用户的选项登录然后我退出时,我收到以下错误。
来自 ElasticSearch 的响应是
array:3 [▼
"took" => 1
"errors" => true
"items" => array:1 [▼
0 => array:1 [▼
"index" => array:5 [▼
"_index" => "users"
"_type" => "_doc"
"_id" => "313"
"status" => 400
"error" => array:3 [▼
"type" => "mapper_parsing_exception"
"reason" => "failed to parse field [created_at] of type [date] in document with id '313'. Preview of field's value: '2021-09-16 11:37:49'"
"caused_by" => array:3 [▼
"type" => "illegal_argument_exception"
"reason" => "failed to parse date field [2021-09-16 11:37:49] with format [strict_date_optional_time||epoch_millis]"
"caused_by" => array:2 [▼
"type" => "date_time_parse_exception"
"reason" => "Failed to parse with all enclosed parsers"
]
]
]
]
]
]
]
这是因为当用户注销时,remember_token 属性被修改,并且由于 User 模型被修改,索引被更新。
问题是当它尝试更新索引时,它尝试存储在索引中的日期格式不再是2021-09-16T14:06:02.000000Z
相反,现在日期格式为 2021-09-16 11:37:49,因此索引中已存在的日期格式与其尝试存储的日期格式存在冲突。
仅当framework 更新User 模型时,当用户logs out 时,才会发生这种情况。
如果我自己更新任何模型的属性,则不会发生这种情况。
UPDATED
我刚刚注意到laravel 更新了remember_token,它禁用了timestamps,这就是日期格式更改为2021-09-16 11:37:49 的原因。
但是,我仍然不知道如何解决这个问题。
【问题讨论】:
标签: laravel elasticsearch laravel-scout