How can I run Elastic Search 5.0 in embed mode?


(Wu Sheng) #1

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?


(Christian Dahlqvist) #2

This blog post contains a discussion about embedding Elasticsearch 5.0. While it may be possible, it is no longer supported.


(Wu Sheng) #3

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


(Jörg Prante) #4

What is your motivation? JUnit testing?


(Wu Sheng) #5

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?


(David Pilato) #6

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


(David Pilato) #7

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


(Jörg Prante) #8

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

See also

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


(Wu Sheng) #9

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

@jprante


(David Pilato) #10

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.


(Wu Sheng) #11

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?


(David Pilato) #12

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


(system) #13

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