# Insert Data into ES 2.1.1 from hive 1.2 HDP2.3

**URL:** https://discuss.elastic.co/t/insert-data-into-es-2-1-1-from-hive-1-2-hdp2-3/38699
**Category:** Elasticsearch
**Tags:** es-hadoop
**Created:** [January 8, 2016, 7:43am UTC](https://discuss.elastic.co/t/insert-data-into-es-2-1-1-from-hive-1-2-hdp2-3/38699 "2016-01-08T07:43:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Shubham\_Srivastava](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Shubham\_Srivastava](https://discuss.elastic.co/u/Shubham_Srivastava)
#### Post date: [January 8, 2016, 7:43am UTC](https://discuss.elastic.co/t/insert-data-into-es-2-1-1-from-hive-1-2-hdp2-3/38699/1 "2016-01-08T07:43:23Z")

</div>

Hi I am facing the while loading data using the recommended way please find attached code , This works perfectly it the target is ES 1.6 but failed for ES 2.1 with String index out of range error PFB the stack trace :  
add jar elasticsearch-hadoop-2.1.1.jar ;  
add jar commons-httpclient-3.1.jar;

CREATE EXTERNAL TABLE marketplace\_olap\_short\_view (  
`order_id` bigint,  
`order_item_id` bigint,  
`fulfillment_id` bigint,  
`promocode_id` bigint,  
`payment_status` int,  
`channel_id` string,  
`so_promocode` string,  
`customer_id` bigint,  
`customer_email` string,  
`customer_firstname` string,  
`customer_lastname` string,  
`customer_type` int,  
`so_remote_ip` string,  
`so_subtotal` bigint,  
`so_order_discount` bigint,  
`so_total` bigint,  
`so_shipping_charges` bigint,  
`so_shipping_amount` bigint,  
`so_grandtotal` bigint,  
`product_id` bigint,  
`vertical_id` bigint,  
`merchant_id` bigint,  
`order_item_creation_date` timestamp

)  
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'  
TBLPROPERTIES('es.resource'='testmktplace/testmktplace',  
'es.index.auto.create' = 'true',  
'es.nodes'='192.168.8.150',  
'[es.mapping.id](http://es.mapping.id)' = 'order\_item\_id',  
'es.write.operation'='upsert',  
'es.batch.size.entries'='10000',  
'es.field.read.empty.as.null' ='true'  
);

insert into table marketplace\_olap\_short\_view  
select COALESCE(order\_id,0), COALESCE(order\_item\_id,0) ,COALESCE(fulfillment\_id,0) ,COALESCE(promocode\_id,0), COALESCE(payment\_status,0) ,COALESCE(channel\_id,"0"), COALESCE(so\_promocode,0), COALESCE(customer\_id,0), COALESCE(customer\_email,"NA"), COALESCE(customer\_firstname,"NA"), COALESCE(customer\_lastname,"NA"), COALESCE(customer\_type,0), COALESCE(so\_remote\_ip,"NA"), so\_subtotal, so\_order\_discount, so\_total, COALESCE(so\_shipping\_charges,0.0), COALESCE(so\_shipping\_amount,0.0), COALESCE(so\_grandtotal,0.0), COALESCE(product\_id,0), vertical\_id, merchant\_id, order\_item\_creation\_date from naved\_workspace.mktplace\_olap limit 10001 ;

Caused by: java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row (tag=0) {"key":{},"value":{"\_col0":1314306859,"\_col1":13630276323,"\_col2":106138893,"\_col3":0,"\_col4":2,"\_col5":"ANDROIDAPP 4.7.0","\_col6":"0","\_col7":15212122710,"\_col8":"asdasdaasd","\_col9":"asda","\_col10":"","\_col11":1,"\_col12":"117.192.17.81","\_col13":360000,"\_col14":0,"\_col15":0,"\_col16":18000.0,"\_col17":18000.0,"\_col18":378000.0,"\_col19":26963933,"\_col20":31,"\_col21":77439,"\_col22":"2015-11-05 21:18:39"}}  
at org.apache.hadoop.hive.ql.exec.tez.ReduceRecordSource.pushRecord(ReduceRecordSource.java:302)  
at org.apache.hadoop.hive.ql.exec.tez.ReduceRecordProcessor.run(ReduceRecordProcessor.java:249)  
at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.initializeAndRunProcessor(TezProcessor.java:148)  
... 14 more  
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row (tag=0) {"key":{},"value":{"\_col0":1314206859,"\_col1":136316323,"\_col2":1067138893,"\_col3":0,"\_col4":2,"\_col5":"ANDROIDAPP 4.7.0","\_col6":"0","\_col7":152122710,"\_col8":"asdasd","\_col9":"asdasd","\_col10":"","\_col11":1,"\_col12":"117.192.17.81","\_col13":360000,"\_col14":0,"\_col15":0,"\_col16":18000.0,"\_col17":18000.0,"\_col18":378000.0,"\_col19":26963933,"\_col20":31,"\_col21":77439,"\_col22":"2015-11-05 21:18:39"}}  
at org.apache.hadoop.hive.ql.exec.tez.ReduceRecordSource$GroupIterator.next(ReduceRecordSource.java:370)  
at org.apache.hadoop.hive.ql.exec.tez.ReduceRecordSource.pushRecord(ReduceRecordSource.java:292)  
... 16 more  
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1  
at java.lang.String.substring(String.java:1911)  
at org.elasticsearch.hadoop.rest.RestClient.discoverNodes(RestClient.java:110)  
at org.elasticsearch.hadoop.rest.InitializationUtils.discoverNodesIfNeeded(InitializationUtils.java:58)  
at org.elasticsearch.hadoop.rest.RestService.createWriter(RestService.java:374)  
at org.elasticsearch.hadoop.mr.EsOutputFormat$EsRecordWriter.init(EsOutputFormat.java:173)  
at org.elasticsearch.hadoop.hive.EsHiveOutputFormat$EsHiveRecordWriter.write(EsHiveOutputFormat.java:58)  
at org.apache.hadoop.hive.ql.exec.FileSinkOperator.process(FileSinkOperator.java:753)  
at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:838)  
at org.apache.hadoop.hive.ql.exec.SelectOperator.process(SelectOperator.java:88)  
at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:838)  
at org.apache.hadoop.hive.ql.exec.LimitOperator.process(LimitOperator.java:54)  
at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:838)  
at org.apache.hadoop.hive.ql.exec.SelectOperator.process(SelectOperator.java:88)  
at org.apache.hadoop.hive.ql.exec.tez.ReduceRecordSource$GroupIterator.next(ReduceRecordSource.java:361)

---

<div class="post-metadata">

### Author: ![Shubham\_Srivastava](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Shubham\_Srivastava](https://discuss.elastic.co/u/Shubham_Srivastava)
#### Post date: [January 8, 2016, 8:45am UTC](https://discuss.elastic.co/t/insert-data-into-es-2-1-1-from-hive-1-2-hdp2-3/38699/2 "2016-01-08T08:45:16Z")

</div>

resolved now used ES 2.2.0 beta connector . ES 2.1.1 connector only supports ES 1.x .

---

<div class="post-metadata">

### Author: ![costin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/costin/32/44950_2.png) [@costin](https://discuss.elastic.co/u/costin)
#### Post date: [January 9, 2016, 2:06pm UTC](https://discuss.elastic.co/t/insert-data-into-es-2-1-1-from-hive-1-2-hdp2-3/38699/3 "2016-01-09T14:06:33Z")

</div>

You might want to try the just released ES-Hadoop 2.2-rc1.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 1:26pm UTC](https://discuss.elastic.co/t/insert-data-into-es-2-1-1-from-hive-1-2-hdp2-3/38699/4 "2017-07-06T13:26:36Z")

</div>


