1.Hive读取ElasticSearch中的数据
程序员文章站
2022-03-08 09:49:38
...
参考教程:https://www.iteblog.com/archives/1857.html
es索引mapping:
{
"104-type": {
"_all": {
"enabled": false
},
"properties": {
"bloodtype": {
"type": "keyword"
},
"byname": {
"type": "keyword"
},
"capTime": {
"type": "long"
},
"ccicFlag": {
"type": "keyword"
},
"companyId": {
"type": "keyword"
},
"createTime": {
"type": "long"
},
"dateOfDeath": {
"type": "date"
},
"dob": {
"type": "date"
},
"dobTime": {
"type": "keyword"
},
"eduDegree": {
"type": "keyword"
},
"enlisted": {
"type": "keyword"
},
"fCardno": {
"type": "keyword"
},
"fCardtype": {
"type": "keyword"
},
"fFirstname": {
"type": "keyword"
},
"fIdentity": {
"type": "keyword"
},
"fNation": {
"type": "keyword"
},
"fSurname": {
"type": "keyword"
},
"faName": {
"type": "keyword"
},
"faPersonId": {
"type": "date"
},
"faPid": {
"type": "keyword"
},
"frozenFlag": {
"type": "keyword"
},
"gender": {
"type": "keyword"
},
"gzdxFlag": {
"type": "keyword"
},
"gzryFlag": {
"type": "keyword"
},
"height": {
"type": "integer"
},
"hujiAddr": {
"type": "keyword"
},
"hujiMetaAddrId": {
"type": "date"
},
"hujiQu": {
"type": "keyword"
},
"hylb": {
"type": "keyword"
},
"job": {
"type": "keyword"
},
"jobType": {
"type": "keyword"
},
"kafkaCreateTime": {
"type": "date"
},
"liveLocation": {
"type": "keyword"
},
"maName": {
"type": "keyword"
},
"maPersonId": {
"type": "date"
},
"maPid": {
"type": "keyword"
},
"mapx": {
"type": "keyword"
},
"mapy": {
"type": "keyword"
},
"marriage": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"namePy": {
"type": "keyword"
},
"natalCountry": {
"type": "keyword"
},
"natalPlace": {
"type": "keyword"
},
"natalXiang": {
"type": "keyword"
},
"nation": {
"type": "keyword"
},
"nativeCountry": {
"type": "keyword"
},
"nativePlace": {
"type": "keyword"
},
"nowAddr": {
"type": "keyword"
},
"nowMetaAddrId": {
"type": "date"
},
"nowQu": {
"type": "keyword"
},
"personDiff": {
"type": "keyword"
},
"personId": {
"type": "date"
},
"personKind": {
"type": "keyword"
},
"personZxbz": {
"type": "keyword"
},
"photoFlag": {
"type": "keyword"
},
"pid": {
"type": "keyword"
},
"religion": {
"type": "keyword"
},
"securityLevel": {
"type": "keyword"
},
"serviceFor": {
"type": "keyword"
},
"smemo": {
"type": "keyword"
},
"source": {
"type": "integer"
},
"sysSource": {
"type": "integer"
},
"type": {
"type": "keyword"
},
"usedName": {
"type": "keyword"
},
"wfryFlag": {
"type": "keyword"
},
"whenCreated": {
"type": "date"
}
}
}
}
1、hive加载操作esjar包
hive> ADD JAR /appslog/hive_jar/elasticsearch-hadoop-2.3.4.jar;
Usage: add [FILE|JAR|ARCHIVE] <value> [<value>]*
Query returned non-zero code: 1, cause: null
2、Hive中创建对应表
ALTER TABLE permanent_population RENAME TO permanent_population_org;
CREATE EXTERNAL TABLE `permanent_population` (
bloodtype string,
byname string,
capTime bigint,
ccicFlag string,
companyId string,
createTime bigint,
dateOfDeath date,
dob date,
dobTime string,
eduDegree string,
enlisted string,
fCardno string,
fCardtype string,
fFirstname string,
fIdentity string,
fNation string,
fSurname string,
faName string,
faPersonId date,
faPid string,
frozenFlag string,
gender string,
gzdxFlag string,
gzryFlag string,
height int,
hujiAddr string,
hujiMetaAddrId date,
hujiQu string,
hylb string,
job string,
jobType string,
kafkaCreateTime date,
liveLocation string,
maName string,
maPersonId date,
maPid string,
mapx string,
mapy string,
marriage string,
NAME string,
namePy string,
natalCountry string,
natalPlace string,
natalXiang string,
nation string,
nativeCountry string,
nativePlace string,
nowAddr string,
nowMetaAddrId date,
nowQu string,
personDiff string,
personId date,
personKind string,
personZxbz string,
photoFlag string,
pid string,
religion string,
securityLevel string,
serviceFor string,
smemo string,
source int,
sysSource int,
type string,
usedName string,
wfryFlag string,
whenCreated date
) STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' TBLPROPERTIES (
'es.resource' = 'gacenter/permanent_population',
'es.nodes' = '172.31.28.205',
'es.port' = '9200',
'es.nodes.wan.only' = 'true',
'es.mapping.names' = 'bloodtype:bloodtype,byname:byname,capTime:capTime,ccicFlag:ccicFlag,companyId:companyId,createTime:createTime,dateOfDeath:dateOfDeath,dob:dob,dobTime:dobTime,eduDegree:eduDegree,enlisted:enlisted,fCardno:fCardno,fCardtype:fCardtype,fFirstname:fFirstname,fIdentity:fIdentity,fNation:fNation,fSurname:fSurname,faName:faName,faPersonId:faPersonId,faPid:faPid,frozenFlag:frozenFlag,gender:gender,gzdxFlag:gzdxFlag,gzryFlag:gzryFlag,height:height,hujiAddr:hujiAddr,hujiMetaAddrId:hujiMetaAddrId,hujiQu:hujiQu,hylb:hylb,job:job,jobType:jobType,kafkaCreateTime:kafkaCreateTime,liveLocation:liveLocation,maName:maName,maPersonId:maPersonId,maPid:maPid,mapx:mapx,mapy:mapy,marriage:marriage,name:name,namePy:namePy,natalCountry:natalCountry,natalPlace:natalPlace,natalXiang:natalXiang,nation:nation,nativeCountry:nativeCountry,nativePlace:nativePlace,nowAddr:nowAddr,nowMetaAddrId:nowMetaAddrId,nowQu:nowQu,personDiff:personDiff,personId:personId,personKind:personKind,personZxbz:personZxbz,photoFlag:photoFlag,pid:pid,religion:religion,securityLevel:securityLevel,serviceFor:serviceFor,smemo:smemo,source:source,sysSource:sysSource,type:type,usedName:usedName,wfryFlag:wfryFlag,whenCreated:whenCreated'
);
注意:建表语句中不能包含tab
上一篇: LeetCode算法面试题汇总之开始之前(3): 搜索二维矩阵 II
下一篇: PHP加密的几种方法
推荐阅读
-
Android中打电话的数据流程分析
-
在ASP.NET 2.0中操作数据之二十五:大数据量时提高分页的效率
-
C#中winform使用相对路径读取文件的方法
-
SQL语句查询数据库中重复记录的个数
-
在ASP.NET 2.0中操作数据之三十二:数据控件的嵌套
-
在ASP.NET 2.0中操作数据之二十八:GridView里的Button
-
在ASP.NET 2.0中操作数据之三十三:基于DataList和Repeater使用DropDownList过滤的主/从报表
-
java8中NIO缓冲区(Buffer)的数据存储详解
-
Java读取properties文件连接数据库的方法示例
-
在ASP.NET 2.0中操作数据之三十:格式化DataList和Repeater的数据