· Map/Reduce integration
· Cascading support
· Apache Hive integration
· Apache Pig support
· Apache Spark support
· Apache Storm support
Elasticsearch 是一个全文检索引擎,与solr一样都是基于lucene实现。
Index 索引 相当于数据库的库名
Type 类型 相当于数据库中的表名
Mapping 文档 相当于数据库的表结构,mapping设计的好坏直接影响搜索效果性能
Field 字段 相当于数据库表的字段
1.下载对应版本的ES-Hadoop jar包。
https://www.elastic.co/downloads/hadoop
2. 将elasticsearch-hadoop-5.1.2.jar 放入hive服务hive.aux.jars.path 所指第三方jar包路径下,hive配置如下:
hive-site.xml configuration.
3.重启hive服务。
常用配置:
es.resource 指定索引名及类型
es.resource = twitter/tweet # index 'twitter', type 'tweet'
es.resource.read
默认es.resource 指定读取索引名及类型es-hive默认
es.resource.write 默认es.resource 指定写入索引名及类型es-hive默认 es.nodes elasticsearch集群节点 如:mynode:9600
es.port http端口默认9200
es.query
从指定的es.resource读取数据的查询,默认为空,如:
es.query = { "query" : { "term" : { "user" : "costinl" } } }
es.input.json false
输入是否为json格式数据
es.write.operation index(
默认)添加新数据,旧数据被替换,重新索引
create
添加新数据,数据存在抛出异常,
update
更新现有数据,不存在抛出异常,
upsert
插入及更新
es.output.json false
输出数据是否为json格式
es.mapping.id
文档id 映射id
es.mapping.names
文档字段 映射hive:es字段 a:a,b:b
es.read.metadata false
是否获取元数据信息
es.read.metadata.field
default _metadata
es.read.metadata.version false 元数据文档版本
es.index.auto.create yes
是否自动创建索引
es.net.http.auth.user
用户名
es.net.http.auth.pass
密码
hive
数据写入 es
1.
建立外部表
CREATE EXTERNAL TABLE artists (
id BIGINT,
name STRING,
links STRUCT
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'
TBLPROPERTIES('es.resource' = 'radio/artists','es.index.auto.create' = 'true',
'es.nodes'='192.168.0.xx','es.port'='9200','es.net.http.auth.user'='test','es.net.http.auth.pass'='123456'
);
2.插入数据
INSERT OVERWRITE TABLE artists
SELECT NULL, 'wf', named_struct('url', 'http://123', 'picture', '10')
3.执行sql查询,测试。
CREATE EXTERNAL TABLE test (
id BIGINT,
name STRING,
links STRUCT
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'
TBLPROPERTIES('es.resource' = 'test/artists','es.index.auto.create' = 'false',
'es.nodes'='192.168.0.xx','es.port'='9200','es.net.http.auth.user'='test','es.net.http.auth.pass'='123456',’es.read.metadata’=’true’
);
注意:我们es集成了search-guard插件,需要配置用户密码