hive--hive2es

–创建es索引

PUT test
{
“settings”: {
“number_of_shards”: 3,
“number_of_replicas”: 2
},
“mapping”: {
“_doc”: {
“properties”: {
“commodity_id”: {
“type”: “long”
},
“commodity_name”: {
“type”: “text”
}
}
}
}
}

–hive创建外部表
ADD JAR hdfs:/user/lib/elasticsearch-hadoop-6.3.2.jar;

drop table if exists tmp.es_test;
CREATE EXTERNAL TABLE tmp.es_test(
id string,
name string,
sex string
) STORED BY ‘org.elasticsearch.hadoop.hive.EsStorageHandler’
TBLPROPERTIES(‘es.resource’=‘test/_doc’,
‘es.nodes.wan.only’ = ‘true’,
‘es.mapping.id’ = ‘id’,
‘es.http.retries’ = ‘0’,
‘es.batch.size.entries’ = ‘500’,
‘es.net.http.auth.pass’=‘aaaaaaa’,
‘es.net.http.auth.user’=‘elastic’,
‘es.nodes’=‘127.0.0.1:9200’
);

CREATE TABLE tmp.test(
id string,
name string,
sex string
)
insert into tmp.test values(1,‘zhangsan’,1);
insert into tmp.test values(2,‘Lisi’,1);
insert into tmp.test values(3,‘wangwu’,0);

insert into tmp.es_test select * from tmp.test ;

hive--hive2es_第1张图片

你可能感兴趣的:(hive)