hive整合es,通过建外联表做映射,数据实际存储在es。注意:hive建内部表时数据存储在hdfs,与es建外联表时,数据存储在es里。
创建表语句demo:
CREATE EXTERNAL TABLE `es.test`(
`id` string,
`keyword` string,
`tenderId` bigint,
`update_time` string,
`type` string,
`request_url` string,
`title` string,
`area` string,
`content` string,
`province` string,
`city` string,
`source` string,
`insert_time` string)
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'
TBLPROPERTIES('es.resource' = 'suoyinname/wendang' --索引名和文档名
, 'es.nodes'='172.**.***.193,172.**.1***.189,172.**.***.190' --主机ip
, 'es.port'='9200' --主机端口
, 'es.mapping.id'='id' --
, 'es.mapping.names'='id:id, keyword:keyword, tenderId:tenderId, update_time:update_time, type:type, request_url:request_url, title:title, area:area, content:content, province:province, city:city, source:source, insert_time:insert_time');--映射字段
参考:https://www.cnblogs.com/lnlvinso/p/7077471.html?utm_source=itdadao&utm_medium=referral