大数据——Hive on ElasticSearch 配置实战(CDH6.3.2)

1、下载相应的jar包

在这里插入图片描述2、

2、添加jar配置

在这里插入图片描述

HIVE_AUX_JARS_PATH=/usr/share/hive

在这里插入图片描述

3、建表语句

1、Elecsearch 存在

 {
    "_index": "es_hive_test",
    "_type": "doc",
    "_id": "w",
    "_score": 1,
    "_source": {
      "id": "23",
      "area": "hangzhou",
      "name": "lisi5"
    }
  }
CREATE EXTERNAL TABLE tmp_test.es_hive_test2 (
cookieid string ,
id string,
area string,
name string 
)
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' 
TBLPROPERTIES('es.nodes' = '10.15.1.41:9200,10.15.1.41:9201,10.15.1.42:9200,10.15.1.42:9201,10.15.1.43:9200,10.15.1.43:9201',
              'es.index.auto.create' = 'flase',
              'es.resource' = 'es_hive_test/doc',
              'es.read.metadata' = 'true',
              'es.index.read.missing.as.empty'='true', --防止查询为空值报错            
'es.net.http.auth.user'='***',
'es.net.http.auth.pass'='***',
'es.mapping.names' = 'cookieid:_metadata._id, 
              id:id,
              area:area, 
              name:name'
              );

2、Elecsearch 不存在

CREATE EXTERNAL TABLE tmp_test.es_hive_test (
cookieid string ,
id string,
area string,
name string 
)
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' 
TBLPROPERTIES('es.nodes' = '10.15.1.41:9200,10.15.1.41:9201,10.15.1.42:9200,10.15.1.42:9201,10.15.1.43:9200,10.15.1.43:9201',
              'es.index.auto.create' = 'true',
              'es.resource' = 'es_hive_test/doc',
              'es.read.metadata' = 'true', 
              'es.mapping.id'='cookieid' ,            
'es.net.http.auth.user'='***',
'es.index.read.missing.as.empty'='true', --防止查询为空值报错
'es.net.http.auth.pass'='***'
'es.mapping.names' = '
              id:id,
              area:area, 
              name:name'
              );

相关参数:
如果是往_id中插入数据,需要设置’es.mapping.id’ = ‘cookieid’参数,表示Hive中的cookieid字段对应到ES中的_id,而es.mapping.names中不需要再映射,这点和读取时候的配置不一样

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值