-- 查看es版本 curl --user elastic:BAGNimgiGBIE5Isu -XGET 'http://es-cn-oew1zs37s000a3616.elasticsearch.aliyuncs.com:9200'
drop table ods.ods_jhff_contentpool_es; add jar hdfs://emr-cluster/es/elasticsearch-hadoop-hive-7.7.1.jar; CREATE EXTERNAL TABLE if not exists ods.ods_jhff_contentpool_es( id ?string ?COMMENT '文章全局id', pub_time bigint ?COMMENT '发布时间时间戳', create_time bigint ?COMMENT '新闻创建时间', audit_create_time bigint ?COMMENT '审核系统入库时间', audit_update_time bigint ?COMMENT '审核系统修改时间', source_id int ?COMMENT '数据源id', source_name string ?COMMENT '数据源名称', article_type string ?COMMENT '文章类型', status ?int ?COMMENT '状态,0正常,1删除/下架,默认是0', title string ?COMMENT '文章标题', category_first string ?COMMENT '一级分类id', category_second string ?COMMENT '二级分类id', category_third string ?COMMENT '三级分类id', last_category int COMMENT '末级分类', media_match boolean COMMENT '媒体匹配情况,true表示匹配成功,false表示不成功,默认为失败', original_type string COMMENT '是否原创新闻,默认为NOT_ORIGINAL', source_download boolean COMMENT '资源下载情况,true表示下载成功,false表示下载失败,默认为下载失败', etl_process_result ?string COMMENT 'etl处理结果,默认为处理结束', can_delivery ?boolean COMMENT '是否可分发,true为可分发,false为不可分发', repeatable_delivery ?boolean COMMENT '是否可重复分发,true表示可重复分发,false表示不可以,默认值为false', is_dup ?int ?COMMENT '是否原创新闻,0原创,1转载' ) STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' TBLPROPERTIES('es.resource' = 'middleground-feedmessage-pool/_doc', 'es.index.auto.create' = 'false', --不自动创建索引 'es.index.read.missing.as.empty'='true',--防止查询为空值报错 'es.mapping.names'='is_dup:isDup,repeatable_delivery:repeatableDelivery,can_delivery:canDelivery,etl_process_result:etlProcessResult,source_download:sourceDownload,original_type:originalType, media_match:mediaMatch,last_category:lastCategory,category_third:categoryThird,category_second:categorySecond,category_first:categoryFirst,title:title,status:status,id:id,pub_time:pubTime,create_time:createTime,audit_create_time:auditCreateTime,audit_update_time:auditUpdateTime,source_id:sourceId,source_name:sourceName,article_type:articleType', --hive字段对应的ES字段,手动指定或自动映射 'es.nodes' = 'es-cn-oew1zs37s000a3616.elasticsearch.aliyuncs.com', 'es.port'='9200', 'es.net.http.auth.pass'='BAGNimgiGBIE5Isu', --ES密码 'es.net.http.auth.user'='elastic', --ES登录名 'es.nodes.wan.only'='true', 'es.nodes.discovery' = 'false', 'es.read.metadata'='true' );
|