Parse rfc 2822 date string to timestamp using update by query

Hi everyone,
I've a bunch of documents inside an index with a string field, created_at, that represents a date in rfc 2822 format (ex.: Thu, 17 Oct 2013 16:09:44 +0000). I've another date field, created_at_time, and I'd like to know if it possibile parse create_at field in date format using script field in update_by_query.

Thank you.

Yes, this is possible. Depending on the version of ES you are using, you should be able to parse this with DateTimeFormatter.RFC_1123_DATE_TIME, and then use the returned TemporalAccessor from parsing to extract time or whatever else you want to store separately.

Note that for update by query, you probably want to check whether the field you are adding has already been added, so that you can "resume" (by making the update a noop) if there is any issue while running your query. The update by query docs should help explain this more.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.