flink1.7.1 写es6外部表没数据问题
你好,只有随机id,没有实际记录写入?截图中没有查询语句,不太清楚是怎么查的。且截图里没看到_source字段。可以参考下这里:https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html 把_source也查出来看下。怎样指定主键?社区文档有指定主键的说明:Key extraction: Flink automatically extracts valid keys from a query. For example, a query SELECT a, b, c FROM t GROUP BY a, b defines a composite key of the fields a and b. The Elasticsearch connector generates a document ID string for every row by concatenating all key fields in the order defined in the query using a key delimiter. A custom representation of null literals for key fields can be defined. (https://ci.apache.org/projects/flink/flink-docs-master/dev/table/connect.html#elasticsearch-connector)即:会分析query,把group by的字段当成主键。比如你想拿id作为主键。sql需要这么写,select id, last_value(name), last_value(value) group by id。表明key是id。last_value是一个自定义的udaf需要你实现下,每次返回最后的值。udaf怎么写可以参考下这个文档:https://ci.apache.org/projects/flink/flink-docs-master/dev/table/udfs.html#aggregation-functions, 也可以看下flink code的MAX实现,MAX返回最大值,LAST_VALUE返回最后一个值,原理差不多。
赞0
踩0