zoukankan      html  css  js  c++  java
  • Hive on ES

      ES对于类似数据库的SQL查询很无力,可以使用Hive on ES来实现SQL的查询。2个百万级的索引做关联时,需要大概1分多钟,基于es2.1版本。

    1.将elasticsearch-hadoop-2.1.1.jar拷贝到hive/lib目录下。

    2.创建hive表

       create external table test(

            name string,

            address  ARRAY<STRING>,

           )

          stored by 'org.elasticsearch.hadoop.hive.EsStorageHandler'

           tblproperties(

              'es.cluster.name'  = 'es',

             'es.resource' = 'datatype/mytype',

             'es.node' = '27.10.1.2,27.10.1.3',

             'es.transport.port' = '9300',

            'es.field.names' = 'name ,address '

         );

        上面的例子中,es中的name字段为string,address为多值字段multi_field ,hive中的数据类型为ARRAY<STRING>。es和hive中数据类型对应关系为:

            int int,

            long bigint,

            float  float,

            double   double,

            string   string,

            multi_field  ARRAY<STRING>,

            birthdy   timestamp

    3.查询

      select * from person p,contact c where p.telephonenum = c.phonenum;

         也可以通过Hive向es中导数据,或者直接读取hdfs数据以scroll bulk方式往es中导数据。

  • 相关阅读:
    时间日期总览
    Mysql一次更新多条数据
    windows远程桌面连接无法粘贴
    vmware workstation pro密钥
    C#自动生成XML文件
    Mysql 缺少MSVCR120DLL问题
    hdu 5672 Strings 模拟
    poj 1328 雷达覆盖 贪心
    hdu 5667 Sequence (矩阵快速幂)
    CodeForces 652D Nested Segments 树状数组
  • 原文地址:https://www.cnblogs.com/lnlvinso/p/7077471.html
Copyright © 2011-2022 走看看