# Develop an Elastic plugin for automatic index restore when you need them

**URL:** <https://discuss.elastic.co/t/develop-an-elastic-plugin-for-automatic-index-restore-when-you-need-them/182516>\
**Category:** Elasticsearch\
**Created:** [May 23, 2019, 8:51pm UTC](https://discuss.elastic.co/t/develop-an-elastic-plugin-for-automatic-index-restore-when-you-need-them/182516 "2019-05-23T20:51:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Victor\_Guimaraes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/victor_guimaraes/32/46749_2.png) [@Victor\_Guimaraes](https://discuss.elastic.co/u/Victor_Guimaraes)\
**Post date:** [May 23, 2019, 8:51pm UTC](https://discuss.elastic.co/t/develop-an-elastic-plugin-for-automatic-index-restore-when-you-need-them/182516/1 "2019-05-23T20:51:51Z")

</div>

Hello

I'm using ElasticSearch 6.7.2 and I have a massive amount of documents organized on daily indexes. So, for financial reasons, I decided to snapshot the old indexes (with more than 9 months) in Google Cloud Storage and only restore them when it's needed.

I installed the GCS repository plugin [https://www.elastic.co/guide/en/elasticsearch/plugins/master/repository-gcs.html](https://www.elastic.co/guide/en/elasticsearch/plugins/master/repository-gcs.html) and the snapshot part are working perfectly and automated using curator. Now, I need to restore my index when my user search for it (long waits are acceptable).

I decided build an Elastic's plugin. This plugin has to verify if the searched index exists or not on cluster. If not, restores it from Cloud Storage. I'm trying to do that with an ActionFilter class , "intercepting" the \_search requests and perform the aforementioned steps.

But I can not check if the index exists in the database. How am I supposed to do that? An ActionFilter class is the correct to use on my case? I cannot find many documentation about build ElasticSearch plugins and many of tutorials I have been finding are deprecated for the newer versions.

Thanks for your attention.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 23, 2019, 9:15pm UTC](https://discuss.elastic.co/t/develop-an-elastic-plugin-for-automatic-index-restore-when-you-need-them/182516/2 "2019-05-23T21:15:10Z")

</div>

Why not using frozen indices? [https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen-indices.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen-indices.html)

Where is the cost you are speaking about ? Disk? Memory ?

---

<div class="post-metadata">

**Author:** ![Victor\_Guimaraes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/victor_guimaraes/32/46749_2.png) [@Victor\_Guimaraes](https://discuss.elastic.co/u/Victor_Guimaraes)\
**Post date:** [May 23, 2019, 9:19pm UTC](https://discuss.elastic.co/t/develop-an-elastic-plugin-for-automatic-index-restore-when-you-need-them/182516/3 "2019-05-23T21:19:08Z")

</div>

Sorry, I should have mentioned it. We talk about disks cost. If I keep all my indices on ElasticSearch's cluster, I will have more or less 32TB of data. Performing the snapshot and restore as aforementioned, I will keep only 2TB of data online on my cluster.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 23, 2019, 9:47pm UTC](https://discuss.elastic.co/t/develop-an-elastic-plugin-for-automatic-index-restore-when-you-need-them/182516/4 "2019-05-23T21:47:54Z")

</div>

What if you use spinning disks or attached slow disks and use [https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen-indices.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen-indices.html)? That could take several minutes to execute the search but at least will remove the burden of writing your own plugin.

---

<div class="post-metadata">

**Author:** ![Victor\_Guimaraes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/victor_guimaraes/32/46749_2.png) [@Victor\_Guimaraes](https://discuss.elastic.co/u/Victor_Guimaraes)\
**Post date:** [May 23, 2019, 10:05pm UTC](https://discuss.elastic.co/t/develop-an-elastic-plugin-for-automatic-index-restore-when-you-need-them/182516/5 "2019-05-23T22:05:23Z")

</div>

I already saw this solution. The problem is again the cost. Using spinning disks my cost will be, on a conservative estimate, 260 times great then the Cloud Storage Solution. So, I chose build the plugin to automated the restore process. I only need to know how test if an index exists or not and how perform the restore inside the Elastic's plugin code.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 23, 2019, 10:23pm UTC](https://discuss.elastic.co/t/develop-an-elastic-plugin-for-automatic-index-restore-when-you-need-them/182516/6 "2019-05-23T22:23:01Z")

</div>

@rjernst might be able to tell if/how this is possible.

---

<div class="post-metadata">

**Author:** ![Victor\_Guimaraes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/victor_guimaraes/32/46749_2.png) [@Victor\_Guimaraes](https://discuss.elastic.co/u/Victor_Guimaraes)\
**Post date:** [May 24, 2019, 7:49pm UTC](https://discuss.elastic.co/t/develop-an-elastic-plugin-for-automatic-index-restore-when-you-need-them/182516/7 "2019-05-24T19:49:04Z")

</div>

For future viewers, I was able to solve the problem Overriding the Plugin class method createComponents and get the Client object parameter. But as you can see in this post [Create a plugin that needs a client](https://discuss.elastic.co/t/create-a-plugin-that-needs-a-client/125142) isn't a beautiful way, but works.

---

<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:** [June 21, 2019, 7:49pm UTC](https://discuss.elastic.co/t/develop-an-elastic-plugin-for-automatic-index-restore-when-you-need-them/182516/8 "2019-06-21T19:49:07Z")

</div>

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