# How to install plugins for embedded elasticsearch?

**URL:** <https://discuss.elastic.co/t/how-to-install-plugins-for-embedded-elasticsearch/7216>\
**Category:** Elasticsearch\
**Created:** [April 3, 2012, 11:31pm UTC](https://discuss.elastic.co/t/how-to-install-plugins-for-embedded-elasticsearch/7216 "2012-04-03T23:31:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_jain/32/834_2.png) [@Eric\_Jain](https://discuss.elastic.co/u/Eric_Jain)\
**Post date:** [April 3, 2012, 11:31pm UTC](https://discuss.elastic.co/t/how-to-install-plugins-for-embedded-elasticsearch/7216/1 "2012-04-03T23:31:16Z")

</div>

To install a plugin into a standalone copy of elasticsearch I can do  
e.g.`bin\plugin -install elasticsearch/elasticsearch-cloud-aws/1.4.0`.  
But how does this work when running elasticsearch embedded in a Java  
application? Do I simple add all the plugin jars to the classpath?

---

<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:** [April 3, 2012, 11:47pm UTC](https://discuss.elastic.co/t/how-to-install-plugins-for-embedded-elasticsearch/7216/2 "2012-04-03T23:47:16Z")

</div>

Yes. Just add the artifact in your pom.xml.

David 😉  
Twitter : @dadoonet / @elasticsearchfr

Le 4 avr. 2012 à 01:31, Eric Jain [eric.jain@gmail.com](mailto:eric.jain@gmail.com) a écrit :

> To install a plugin into a standalone copy of elasticsearch I can do  
> e.g.`bin\plugin -install elasticsearch/elasticsearch-cloud-aws/1.4.0`.  
> But how does this work when running elasticsearch embedded in a Java  
> application? Do I simple add all the plugin jars to the classpath?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 4, 2012, 3:07pm UTC](https://discuss.elastic.co/t/how-to-install-plugins-for-embedded-elasticsearch/7216/3 "2012-04-04T15:07:15Z")

</div>

Yes, you just need to have the plugin jars in the classpath.

On Wed, Apr 4, 2012 at 2:31 AM, Eric Jain [eric.jain@gmail.com](mailto:eric.jain@gmail.com) wrote:

> To install a plugin into a standalone copy of elasticsearch I can do  
> e.g.`bin\plugin -install elasticsearch/elasticsearch-cloud-aws/1.4.0`.  
> But how does this work when running elasticsearch embedded in a Java  
> application? Do I simple add all the plugin jars to the classpath?

---

<div class="post-metadata">

**Author:** ![clandestino\_bgd\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/clandestino_bgd_2/32/1315_2.png) [@clandestino\_bgd\_2](https://discuss.elastic.co/u/clandestino_bgd_2)\
**Post date:** [December 5, 2012, 11:39pm UTC](https://discuss.elastic.co/t/how-to-install-plugins-for-embedded-elasticsearch/7216/4 "2012-12-05T23:39:22Z")

</div>

Hi,  
I need to install es-head plugin automatically on start of my embedded ES.  
This plugin isn't get installed as jar, but as a site, if I am not mistaken?  
What would be the best way to do this?  
Thanks,  
Milan

On Wednesday, 4 April 2012 16:07:15 UTC+1, kimchy wrote:

> Yes, you just need to have the plugin jars in the classpath.
> 
> On Wed, Apr 4, 2012 at 2:31 AM, Eric Jain \<[eric...@gmail.com](mailto:eric...@gmail.com) \<javascript:\>
> 
> > wrote:
> 
> > To install a plugin into a standalone copy of elasticsearch I can do  
> > e.g.`bin\plugin -install elasticsearch/elasticsearch-cloud-aws/1.4.0`.  
> > But how does this work when running elasticsearch embedded in a Java  
> > application? Do I simple add all the plugin jars to the classpath?

--

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [December 6, 2012, 8:39am UTC](https://discuss.elastic.co/t/how-to-install-plugins-for-embedded-elasticsearch/7216/5 "2012-12-06T08:39:02Z")

</div>

You have two options for plugin automatic installs.

The first is most convenient, just unpack ES, install the plugins,  
repackage ES, distribute it. This is also easy for later updates.

Second, if you don't want to prepackage ES with plugins (maybe due to  
license issues or if the plugins to get installed are unknown at this time,  
or customers shouldn't use the bin/plugin method for whatever reason), you  
could try to add a function to your code. Try something like this (taken  
from org.elasticsearch.plugins.PluginManager)

```
    Tuple<Settings, Environment> initialSettings = 

```

InternalSettingsPerparer.prepareSettings(EMPTY\_SETTINGS, true);  
if (!initialSettings.v2().pluginsFile().exists()) {  
FileSystemUtils.mkdirs(initialSettings.v2().pluginsFile());  
}  
String url = null;  
PluginManager pluginManager = new  
PluginManager(initialSettings.v2(),url);  
pluginManager.downloadAndExtract( "mylovely//1.0.0",  
true);

Adjust 'url' to the URL where the plugin is located, or null to download  
form github.

The HTTP server inside the ES node should now redirect requests to port  
92xx and path /\_plugin// to the site plugin files.

Note, if it is not a site plugin, the node needs a restart for plugin  
initialization.

Jörg

--

---

<div class="post-metadata">

**Author:** ![Bibin\_Abraham](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@Bibin\_Abraham](https://discuss.elastic.co/u/Bibin_Abraham)\
**Post date:** [October 28, 2013, 3:17pm UTC](https://discuss.elastic.co/t/how-to-install-plugins-for-embedded-elasticsearch/7216/6 "2013-10-28T15:17:20Z")

</div>

Hi Jörg,

I have embedded ES in a tomcat container to use it as a web app. I have  
referenced twitter plugin and created a subclass of AbstractPlugin. Now in  
the elasticsearch.yml settings, what path should I give for the plugin  
directory?

Thanks & Regards

bin

On Thursday, 6 December 2012 14:09:02 UTC+5:30, Jörg Prante wrote:

> You have two options for plugin automatic installs.
> 
> The first is most convenient, just unpack ES, install the plugins,  
> repackage ES, distribute it. This is also easy for later updates.
> 
> Second, if you don't want to prepackage ES with plugins (maybe due to  
> license issues or if the plugins to get installed are unknown at this time,  
> or customers shouldn't use the bin/plugin method for whatever reason), you  
> could try to add a function to your code. Try something like this (taken  
> from org.elasticsearch.plugins.PluginManager)
> 
> ```
> Tuple<Settings, Environment> initialSettings = 
> 
> ```
> 
> InternalSettingsPerparer.prepareSettings(EMPTY\_SETTINGS, true);  
> if (!initialSettings.v2().pluginsFile().exists()) {  
> FileSystemUtils.mkdirs(initialSettings.v2().pluginsFile());  
> }  
> String url = null;  
> PluginManager pluginManager = new  
> PluginManager(initialSettings.v2(),url);  
> pluginManager.downloadAndExtract( "mylovely//1.0.0",  
> true);
> 
> Adjust 'url' to the URL where the plugin is located, or null to download  
> form github.
> 
> The HTTP server inside the ES node should now redirect requests to port  
> 92xx and path /\_plugin// to the site plugin files.
> 
> Note, if it is not a site plugin, the node needs a restart for plugin  
> initialization.
> 
> Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [October 28, 2013, 3:49pm UTC](https://discuss.elastic.co/t/how-to-install-plugins-for-embedded-elasticsearch/7216/7 "2013-10-28T15:49:52Z")

</div>

Not sure how you handle twitter plugin, by downloadAndExtract? Or do you  
prepackage it in your war?

You do not need a plugin path at all, as long as es-plugin.properties in  
the jar root of the plugin is visible in the classpath of the war where you  
start the embedded node.

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![roytmana](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roytmana/32/44855_2.png) [@roytmana](https://discuss.elastic.co/u/roytmana)\
**Post date:** [October 28, 2013, 6:21pm UTC](https://discuss.elastic.co/t/how-to-install-plugins-for-embedded-elasticsearch/7216/8 "2013-10-28T18:21:32Z")

</div>

If it is a site plugin I am not sure transport wares servlet would forward to plugins. It didn't work for me no matter how I tried to configure it. I ended up subclassing transport wares servlet and implementing all plufin forwarding logic myself

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:10am UTC](https://discuss.elastic.co/t/how-to-install-plugins-for-embedded-elasticsearch/7216/9 "2017-07-06T02:10:10Z")

</div>


