Apache SeaTunnel PostgreSQL 到 Elasticsearch 数据迁移配置示例
以下是一个 Apache SeaTunnel 配置的例子,用于将数据从 PostgreSQL 读取并写入 Elasticsearch:
{
'sources': [
{
'name': 'postgres_source',
'type': 'postgres',
'config': {
'host': 'localhost',
'port': 5432,
'username': 'postgres',
'password': 'password',
'database': 'my_database',
'table': 'my_table',
'columns': [
{'name': 'id', 'type': 'integer'},
{'name': 'name', 'type': 'string'},
{'name': 'age', 'type': 'integer'}
]
}
}
],
'destinations': [
{
'name': 'es_destination',
'type': 'elasticsearch',
'config': {
'hosts': ['http://localhost:9200'],
'index': 'my_index',
'type': 'my_type',
'id_field': 'id',
'bulk_size': 100,
'bulk_interval': 1000
}
}
],
'transformations': [
{
'type': 'rename',
'config': {
'from': 'name',
'to': 'full_name'
}
}
],
'mappings': [
{
'source': 'postgres_source',
'destination': 'es_destination',
'transformations': [
{'type': 'rename', 'config': {'from': 'name', 'to': 'full_name'}},
{'type': 'convert', 'config': {'from': 'id', 'to': 'string'}},
{'type': 'convert', 'config': {'from': 'age', 'to': 'string'}}
]
}
]
}
这个配置文件定义了一个名为'postgres_source'的 PostgreSQL 源,它从'my_database' 数据库中的'my_table' 表读取数据。源有三列:'id', 'name' 和 'age'。
此外,配置文件还定义了一个名为'es_destination' 的 Elasticsearch 目标。目标是将数据写入名为'my_index' 的索引中,并在索引中创建一个名为'my_type' 的类型。目标使用'id' 列作为文档 ID,并每 100 毫秒将 100 个文档作为一个批次写入 Elasticsearch。
配置文件还包括一个转换,将'name' 列重命名为'full_name'。
最后,配置文件定义了一个映射,将数据从'postgres_source' 源转换为'es_destination' 目标。映射使用转换将'name' 列重命名为'full_name',并将'id' 和 'age' 列转换为字符串类型。
原文地址: http://www.cveoy.top/t/topic/oUGR 著作权归作者所有。请勿转载和采集!