# ES-Hadoop overwrite the external table

**URL:** <https://discuss.elastic.co/t/es-hadoop-overwrite-the-external-table/101540>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [September 22, 2017, 9:02pm UTC](https://discuss.elastic.co/t/es-hadoop-overwrite-the-external-table/101540 "2017-09-22T21:02:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![EvelynC](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@EvelynC](https://discuss.elastic.co/u/EvelynC)\
**Post date:** [September 22, 2017, 9:02pm UTC](https://discuss.elastic.co/t/es-hadoop-overwrite-the-external-table/101540/1 "2017-09-22T21:02:10Z")

</div>

Hi everyone,

According to all I know, the external table which is just a link to the data stored in ES, and we can only insert appendant data or delete all of them. Is there any way to overwrite the data? such as just deleting some selected columns of it, rather than deleting all of them and load new data again.  
I saw there is a similar topic, but it was asked in '15, here is the link:

> [@ES-Hadoop 2.0.2 jars and INSERT OVERWRITE](https://discuss.elastic.co/t/es-hadoop-2-0-2-jars-and-insert-overwrite/24091/3):
>
> Hallo Costin, Thanks for your reply. The standard Hive behaviour with internal tables (certainly with partitions) is that Hive empties the target location/partition and writes the new data afresh. With EXTERNAL TABLES that is a grey area as the data does not strictly "belong" to Hive, so I can understand why a delete does not happen (I would think the most elegant implementation would be to control this behaviour via a property, as is done with e.g.'es.index.auto.create', although DELETEs are t…

so I am wondering that are there any changes made recently?

Thanks!

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [October 4, 2017, 3:45am UTC](https://discuss.elastic.co/t/es-hadoop-overwrite-the-external-table/101540/2 "2017-10-04T03:45:25Z")

</div>

It depends on your use case. ES-Hadoop does not support performing delete operations for ES as delete operations are fairly costly to perform from a distributed computing environment (to delete the doc, you need to pull it's information, just to get its ID to remove it). What kind of use case are you looking to satisfy with these delete by column value access patterns? I'm wondering if there are better recipes to make your workload more Elasticsearch friendly.

---

<div class="post-metadata">

**Author:** ![EvelynC](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@EvelynC](https://discuss.elastic.co/u/EvelynC)\
**Post date:** [October 4, 2017, 5:54pm UTC](https://discuss.elastic.co/t/es-hadoop-overwrite-the-external-table/101540/3 "2017-10-04T17:54:33Z")

</div>

Thank you for the reply!  
Actually all I want to do is to replace the old data with the new data, which is overwrite, but all I can do now is to delete the old data by using the curl -XDELETE, then insert the data into ES table from hive. But actually it seems do not matter, but if there is better one, that definitely will be better.  
Thanks again!

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [October 4, 2017, 6:09pm UTC](https://discuss.elastic.co/t/es-hadoop-overwrite-the-external-table/101540/4 "2017-10-04T18:09:20Z")

</div>

If your data has unique id's for each record, you could instruct the ES-Hadoop connector to use the `update`/`upsert` operation when performing writes. In this case, when the job emits a record, Elasticsearch will track down the previous record data and replace it with the one being written. In the case of `upsert`, if the record does not exist, Elasticsearch will just create it instead of throwing an error.

---

<div class="post-metadata">

**Author:** ![EvelynC](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@EvelynC](https://discuss.elastic.co/u/EvelynC)\
**Post date:** [October 4, 2017, 6:21pm UTC](https://discuss.elastic.co/t/es-hadoop-overwrite-the-external-table/101540/5 "2017-10-04T18:21:27Z")

</div>

Thank you!  
I will try this!

---

<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:** [November 1, 2017, 6:21pm UTC](https://discuss.elastic.co/t/es-hadoop-overwrite-the-external-table/101540/6 "2017-11-01T18:21:29Z")

</div>

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