# How can I run Elastic Search 5.0 in embed mode?

**URL:** <https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595>\
**Category:** Elasticsearch\
**Created:** [November 30, 2016, 10:46am UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595 "2016-11-30T10:46:18Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![wu-sheng](https://avatars.discourse-cdn.com/v4/letter/w/ed8c4c/32.png) [@wu-sheng](https://discuss.elastic.co/u/wu-sheng)\
**Post date:** [November 30, 2016, 10:46am UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/1 "2016-11-30T10:46:18Z")

</div>

Do I have any opportunities to embed es(Elastic Search)? In another way, run it in the same JVM. And my code call use api instead of http/socket api to access es?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [November 30, 2016, 11:23am UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/2 "2016-11-30T11:23:08Z")

</div>

[This blog post](https://www.elastic.co/blog/elasticsearch-the-server) contains a discussion about embedding Elasticsearch 5.0. While it may be possible, it is no longer supported.

---

<div class="post-metadata">

**Author:** ![wu-sheng](https://avatars.discourse-cdn.com/v4/letter/w/ed8c4c/32.png) [@wu-sheng](https://discuss.elastic.co/u/wu-sheng)\
**Post date:** [November 30, 2016, 11:35am UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/3 "2016-11-30T11:35:52Z")

</div>

Do you know anyone, who did this in 5.0 successfully?

---

<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:** [November 30, 2016, 12:46pm UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/4 "2016-11-30T12:46:31Z")

</div>

What is your motivation? JUnit testing?

---

<div class="post-metadata">

**Author:** ![wu-sheng](https://avatars.discourse-cdn.com/v4/letter/w/ed8c4c/32.png) [@wu-sheng](https://discuss.elastic.co/u/wu-sheng)\
**Post date:** [November 30, 2016, 1:26pm UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/5 "2016-11-30T13:26:23Z")

</div>

No just jUnit test. I have a application focus on storage on local disk, in order to find data quickly, I write byte[] into file, and save file\_name, offset, length of the data into de es. Most important, the process of my app and the process of es is 1:1. So es is not in cluster mode, and no need in cluster mode.

Now I use a network api to save data, but I think this is not efficient enough. So I look the better way to do so.

Does anyone have better ideas?

---

<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:** [November 30, 2016, 1:42pm UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/6 "2016-11-30T13:42:11Z")

</div>

If you don't want to do integration tests, you can just Mock ES, no?

---

<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:** [November 30, 2016, 1:42pm UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/7 "2016-11-30T13:42:12Z")

</div>

If you don't want to do integration tests, you can just Mock ES, no?

---

<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:** [November 30, 2016, 1:42pm UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/8 "2016-11-30T13:42:52Z")

</div>

You don't need to go over the network. If you want to depart from the "supported version" path, you can try something like a standalone node. I use this approach as a "mock node" for lightweight JUnit tests which run in a single JVM

[https://github.com/xbib/elasticsearch-extras-client/blob/es5/src/integration-test/java/org/elasticsearch/node/MockNode.java](https://github.com/xbib/elasticsearch-extras-client/blob/es5/src/integration-test/java/org/elasticsearch/node/MockNode.java)

See also

[https://github.com/xbib/elasticsearch-extras-client/blob/es5/src/integration-test/java/org/xbib/elasticsearch/NodeTestBase.java#L195-L196](https://github.com/xbib/elasticsearch-extras-client/blob/es5/src/integration-test/java/org/xbib/elasticsearch/NodeTestBase.java#L195-L196)

---

<div class="post-metadata">

**Author:** ![wu-sheng](https://avatars.discourse-cdn.com/v4/letter/w/ed8c4c/32.png) [@wu-sheng](https://discuss.elastic.co/u/wu-sheng)\
**Post date:** [November 30, 2016, 1:46pm UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/9 "2016-11-30T13:46:41Z")

</div>

I am not running in test or need mock. I want to run in product env.  
No cluster mode is what I need.

@jprante

---

<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:** [November 30, 2016, 1:59pm UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/10 "2016-11-30T13:59:12Z")

</div>

IMO if you need a 3rd party service to test your code, then it's not a unit test but an integration test, which is a different story than embedding a node.

---

<div class="post-metadata">

**Author:** ![wu-sheng](https://avatars.discourse-cdn.com/v4/letter/w/ed8c4c/32.png) [@wu-sheng](https://discuss.elastic.co/u/wu-sheng)\
**Post date:** [November 30, 2016, 2:02pm UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/11 "2016-11-30T14:02:12Z")

</div>

Again, it is not test. Sorry for the mislead anyone thought, it for unit test.  
It is need in running time, use embed mode to avoid network cost.  
Is this clear enough?

---

<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:** [November 30, 2016, 2:16pm UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/12 "2016-11-30T14:16:16Z")

</div>

I see. As @Christian_Dahlqvist said, it's not supported.  
As @jprante wrote, you have a workaround.

---

<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:** [December 28, 2016, 2:16pm UTC](https://discuss.elastic.co/t/how-can-i-run-elastic-search-5-0-in-embed-mode/67595/13 "2016-12-28T14:16:39Z")

</div>

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