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中导数据。

  • 相关阅读:
    JavaScript
    94.Binary Tree Inorder Traversal
    144.Binary Tree Preorder Traversal
    106.Construct Binary Tree from Inorder and Postorder Traversal
    105.Construct Binary Tree from Preorder and Inorder Traversal
    90.Subsets II
    78.Subsets
    83.Merge Sorted Array
    80.Remove Duplicates from Sorted Array II
    79.Word Search
  • 原文地址:https://www.cnblogs.com/lnlvinso/p/7077471.html
Copyright © 2011-2022 走看看