SparkSql 写 Es

官方文档

key 备注
es.write.operation index(默认)添加新数据,旧数据被替换,重新索引;create添加新数据,数据存在抛出异常;update 更新现有数据,不存在抛出异常,upsert 插入及更新
es.mapping.id _id es的doc_id

出仓脚本exg:

CREATE TEMPORARY VIEW table_name 
(
    `id` STRING COMMENT 'id',
    `id2` BIGINT COMMENT 'id2'
) USING org.elasticsearch.spark.sql OPTIONS (
    resource 'index_version/_doc',
    nodes 'xxx'
     	,port '9200'
        ,scroll_size '50'
        ,nodes_client_only 'true'
        ,nodes_data_only 'false'
		,es.mapping.id 'id'
        ,es.write.operation 'upsert'
        ,es.batch.write.retry.count '6'
        ,es.batch.write.retry.wait '20s'
);

-- 只出仓维度
insert into table table_name
(select id,
        id2
 from table_name_source
 where xxx
)
posted @   Eiffelzero  阅读(91)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
点击右上角即可分享
微信分享提示