You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ma...@apache.org on 2022/04/25 11:52:37 UTC
[flink-connector-elasticsearch] 14/21: [FLINK-24571][connectors/elasticsearch] Supports a system time function(now() and current_timestamp) in index pattern
This is an automated email from the ASF dual-hosted git repository.
martijnvisser pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-connector-elasticsearch.git
commit 3153557bbe2ca9bde7dd540dcb1347d2a326205c
Author: jinfeng <ji...@gmail.com>
AuthorDate: Thu Dec 9 20:36:48 2021 +0800
[FLINK-24571][connectors/elasticsearch] Supports a system time function(now() and current_timestamp) in index pattern
---
docs/content.zh/docs/connectors/table/elasticsearch.md | 4 ++++
docs/content/docs/connectors/table/elasticsearch.md | 5 +++++
2 files changed, 9 insertions(+)
diff --git a/docs/content.zh/docs/connectors/table/elasticsearch.md b/docs/content.zh/docs/connectors/table/elasticsearch.md
index a3f6001..339d9d5 100644
--- a/docs/content.zh/docs/connectors/table/elasticsearch.md
+++ b/docs/content.zh/docs/connectors/table/elasticsearch.md
@@ -263,6 +263,10 @@ Elasticsearch sink 同时支持静态索引和动态索引。
`date_format_string` 与 Java 的 [DateTimeFormatter](https://docs.oracle.com/javase/8/docs/api/index.html) 兼容。
例如,如果选项值设置为 `'myusers-{log_ts|yyyy-MM-dd}'`,则 `log_ts` 字段值为 `2020-03-27 12:25:55` 的记录将被写入到 "myusers-2020-03-27" 索引中。
+你也可以使用 `'{now()|date_format_string}'` 将当前的系统时间转换为 `date_format_string` 指定的格式。`now()` 对应的时间类型是 `TIMESTAMP_WITH_LTZ` 。
+在将系统时间格式化为字符串时会使用 session 中通过 `table.local-time-zone` 中配置的时区。 使用 `NOW()`, `now()`, `CURRENT_TIMESTAMP`, `current_timestamp` 均可以。
+
+**注意:** 使用当前系统时间生成的动态索引时, 对于 changelog 的流,无法保证同一主键对应的记录能产生相同的索引名, 因此使用基于系统时间的动态索引,只能支持 append only 的流。
数据类型映射
----------------
diff --git a/docs/content/docs/connectors/table/elasticsearch.md b/docs/content/docs/connectors/table/elasticsearch.md
index 1054c6f..78d0ce9 100644
--- a/docs/content/docs/connectors/table/elasticsearch.md
+++ b/docs/content/docs/connectors/table/elasticsearch.md
@@ -298,6 +298,11 @@ You can also use `'{field_name|date_format_string}'` to convert a field value of
The `date_format_string` is compatible with Java's [DateTimeFormatter](https://docs.oracle.com/javase/8/docs/api/index.html).
For example, if the option value is `'myusers-{log_ts|yyyy-MM-dd}'`, then a record with `log_ts` field value `2020-03-27 12:25:55` will be written into "myusers-2020-03-27" index.
+You can also use `'{now()|date_format_string}'` to convert the current system time to the format specified by `date_format_string`. The corresponding time type of `now()` is `TIMESTAMP_WITH_LTZ`.
+When formatting the system time as a string, the time zone configured in the session through `table.local-time-zone` will be used. You can use `NOW()`, `now()`, `CURRENT_TIMESTAMP`, `current_timestamp`.
+
+**NOTE:** When using the dynamic index generated by the current system time, for changelog stream, there is no guarantee that the records with the same primary key can generate the same index name.
+Therefore, the dynamic index based on the system time can only support append only stream.
Data Type Mapping
----------------