Search code examples
elasticsearchsolrj

elasticsearch equivalent of EmbeddedSolrServer for Solr


Is it possible to update index built using elastic search without the overheads of http and serialization? I am searching for an elasticsearch equivalent of EmbeddedSolrServer available with solrj.


Solution

  • Sure it is, with elasticsearch you can easily start up a local node and embed it in your application.

    With local node I mean with local discovery, local within the jvm.

    Have a look at the Java API documentation, where there's an example on how to startup a local node:

    Node node = nodeBuilder().local(true).node();
    Client client = node.client();
    

    Don't forget to shut it down when you're done:

    node.close();
    

    Have a look at this blog I wrote too: elasticsearch beyond big data - running elasticsearch embedded.