# Indexing from hdfs to elasticsearch using Pig

**URL:** <https://discuss.elastic.co/t/indexing-from-hdfs-to-elasticsearch-using-pig/40374>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [January 28, 2016, 2:42pm UTC](https://discuss.elastic.co/t/indexing-from-hdfs-to-elasticsearch-using-pig/40374 "2016-01-28T14:42:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anshul\_Bhatnagar](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Anshul\_Bhatnagar](https://discuss.elastic.co/u/Anshul_Bhatnagar)\
**Post date:** [January 28, 2016, 2:42pm UTC](https://discuss.elastic.co/t/indexing-from-hdfs-to-elasticsearch-using-pig/40374/1 "2016-01-28T14:42:56Z")

</div>

A= LOAD 'hdfs://10.70.16.91:8020/travel\_stats/travel/stats-1453945200000/part-00001' USING PigStorage('\t');

STORE A INTO 'logs/travels' USING org.elasticsearch.hadoop.pig.EsStorage('es.nodes=xx.xx.xx.xx,xx.xx.xx.xx,xx.xx.xx.xx','es.port=9200','es.index.auto.create = true' );

java.lang.Exception: java.lang.StringIndexOutOfBoundsException: String index out of range: -1

Counters:  
Total records written : 0  
Total bytes written : 0  
Spillable Memory Manager spill count : 0  
Total bags proactively spilled: 0  
Total records proactively spilled: 0

Please help.

---

<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 28, 2016, 10:20pm UTC](https://discuss.elastic.co/t/indexing-from-hdfs-to-elasticsearch-using-pig/40374/2 "2016-01-28T22:20:55Z")

</div>

You are using ES 2.x with ES-Hadoop 2.0 or 2.1. For ES 2.x, you need to use ES-Hadoop 2.2 (currently rc1) as well.

---

<div class="post-metadata">

**Author:** ![Anshul\_Bhatnagar](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Anshul\_Bhatnagar](https://discuss.elastic.co/u/Anshul_Bhatnagar)\
**Post date:** [January 29, 2016, 5:15am UTC](https://discuss.elastic.co/t/indexing-from-hdfs-to-elasticsearch-using-pig/40374/3 "2016-01-29T05:15:54Z")

</div>

I am using ES 2.1.1 with ES-Hadoop 2.1.1.

Thanks it worked with ES-Hadoop 2.2.0 rc1

---

<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 29, 2016, 10:49am UTC](https://discuss.elastic.co/t/indexing-from-hdfs-to-elasticsearch-using-pig/40374/4 "2016-01-29T10:49:56Z")

</div>

Cheers. ES-Hadoop 2.1.3 will provide a better exception message.

---

<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/indexing-from-hdfs-to-elasticsearch-using-pig/40374/5 "2017-07-06T13:26:19Z")

</div>


