# Read from elasticsearch into Hive

**URL:** https://discuss.elastic.co/t/read-from-elasticsearch-into-hive/71277
**Category:** Elasticsearch
**Tags:** es-hadoop
**Created:** [January 11, 2017, 8:18pm UTC](https://discuss.elastic.co/t/read-from-elasticsearch-into-hive/71277 "2017-01-11T20:18:15Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![krishna\_chaitanya](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@krishna\_chaitanya](https://discuss.elastic.co/u/krishna_chaitanya)
#### Post date: [January 11, 2017, 8:18pm UTC](https://discuss.elastic.co/t/read-from-elasticsearch-into-hive/71277/1 "2017-01-11T20:18:15Z")

</div>

Hi,

In the [documentation](https://www.elastic.co/guide/en/elasticsearch/hadoop/current/hive.html#_reading_data_from_elasticsearch_2), Hive external table is being used to map the data from Elasticsearch index.

Does the external table in Hive store the data once it is created? say in `user/hive/warehouse`?  
Or for every `select` query, the data is fetched from elasticsearch instead?

---

<div class="post-metadata">

### Author: ![krishna\_chaitanya](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@krishna\_chaitanya](https://discuss.elastic.co/u/krishna_chaitanya)
#### Post date: [January 12, 2017, 3:45pm UTC](https://discuss.elastic.co/t/read-from-elasticsearch-into-hive/71277/2 "2017-01-12T15:45:24Z")

</div>

I configured the elasticsearch for hadoop and using this with with Hive.

I created an external table to read ES data into Hive. After I performed a select query, I can see the data on Hive. But, the external table's storage directory (in my case`/user/hive/warehouse/<table_name>`) is empty. I cannot see any data in there. So, Hive doesn't store the data? For each query in Hive, it fetches the data from elasticsearch?

---

<div class="post-metadata">

### Author: ![Tommaso\_Anzidei](https://avatars.discourse-cdn.com/v4/letter/t/8797f3/32.png) [@Tommaso\_Anzidei](https://discuss.elastic.co/u/Tommaso_Anzidei)
#### Post date: [January 13, 2017, 9:17am UTC](https://discuss.elastic.co/t/read-from-elasticsearch-into-hive/71277/3 "2017-01-13T09:17:08Z")

</div>

Hi,  
the data stays in Elasticsearch. The External table works like a view of the ES index. You can even drop the external table and your index will not be deleted. And yes, every time you query the external table you are querying elasticsearch again (that is slow). So I use to create an external table and then I create new tables in hive selecting the data from the external table. This new tables are permanent hive tables.

---

<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: [February 10, 2017, 9:17am UTC](https://discuss.elastic.co/t/read-from-elasticsearch-into-hive/71277/4 "2017-02-10T09:17:24Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
