# Embedded ElasticSearch On JAVA API

**URL:** <https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021>\
**Category:** Elasticsearch\
**Created:** [March 15, 2012, 8:30pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021 "2012-03-15T20:30:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![samCougars](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@samCougars](https://discuss.elastic.co/u/samCougars)\
**Post date:** [March 15, 2012, 8:30pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021/1 "2012-03-15T20:30:54Z")

</div>

All  
I am using Embedded ElasticSearch On JAVA API. It is creating indexes  
correctly.  
Once I create the index, I see a folder "elasticSearch" under my home  
directory. But even after I remove this "elasticSearch" folder from my  
home directory, it still performs the searches. Is it being stored  
somewhere else too? Sometime while debugging I need to get rid of the  
contents of this elastic folder, and start all over again. So, is  
there any other place I need to remove elasticSearch indexes on my  
box?  
Thanks

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [March 15, 2012, 9:32pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021/2 "2012-03-15T21:32:22Z")

</div>

Hi,

check here  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/setup/dir-layout.html) for  
folder locations used by ES and how they can be configured (some of them  
support multi locations).

You need to know how these locations are configured in your case. The  
chance is that you are using in-memory indices which means that Lucene  
segments are not found on the disk. You can also use gateway of type none  
(which again means the gateway data is not stored on the disk). This is  
typically used during unit tests. You can find a lot of examples in ES unit  
test code, or you can check one example that I uploaded to github some time  
ago:

> <https://github.com/lukas-vlcek/elasticsearch.demo/tree/master/src/test/java/org/elasticsearch/demo>
>
> //github.com/lukas-vlcek/elasticsearch.demo/tree/master/src/test/java/org/elasticsearch/demo

Check both abstract and basic test class, how the paths are configured and  
how I clean up after test.

Regards,  
Lukas

On Thu, Mar 15, 2012 at 9:30 PM, Sam [sbaniya@gmail.com](mailto:sbaniya@gmail.com) wrote:

> All  
> I am using Embedded Elasticsearch On JAVA API. It is creating indexes  
> correctly.  
> Once I create the index, I see a folder "elasticSearch" under my home  
> directory. But even after I remove this "elasticSearch" folder from my  
> home directory, it still performs the searches. Is it being stored  
> somewhere else too? Sometime while debugging I need to get rid of the  
> contents of this elastic folder, and start all over again. So, is  
> there any other place I need to remove elasticSearch indexes on my  
> box?  
> Thanks

---

<div class="post-metadata">

**Author:** ![samCougars](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@samCougars](https://discuss.elastic.co/u/samCougars)\
**Post date:** [March 16, 2012, 10:42pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021/3 "2012-03-16T22:42:06Z")

</div>

This is how I'm doing in java api:  
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();  
settings.put("path.home",System.getProperty("user.home")+"/elasticSearch");  
settings.put("number\_of\_shards",1);  
settings.put("number\_of\_replicas",0);  
Node node = NodeBuilder.nodeBuilder().settings(settings).clusterName("firstCluster").node();

Client client = node.client();  
client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();

client.prepareIndex("searchdata", "exhibitor", "9999").setSource("My data information").execute().actionGet();

When I use this to create node and index, it creates the folder "elasticSearch" under my home directory. But even after I remove "elasticSearch", it still does search. So I have no clue where it is grabbing the indexed data after I have completely deleted "elasticSearch". Any suggestions?  
Thanks

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [March 20, 2012, 11:41am UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021/4 "2012-03-20T11:41:01Z")

</div>

Hi,

it is hard to answer this question without complete code example but may be  
the reason is that the index data are still in memory because it hasn't  
been flushed yet.  
See

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Regards,  
Lukas

On Fri, Mar 16, 2012 at 11:42 PM, samCougars [sbaniya@gmail.com](mailto:sbaniya@gmail.com) wrote:

> This is how I'm doing in java api:  
> ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();  
> settings.put("path.home",System.getProperty("user.home")+"/elasticSearch");  
> settings.put("number\_of\_shards",1);  
> settings.put("number\_of\_replicas",0);  
> Node node =
> 
> NodeBuilder.nodeBuilder().settings(settings).clusterName("firstCluster").node();
> 
> Client client = node.client();
> 
> client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
> 
> client.prepareIndex("searchdata", "exhibitor", "9999").setSource("My data  
> information").execute().actionGet();
> 
> When I use this to create node and index, it creates the folder  
> "elasticSearch" under my home directory. But even after I remove  
> "elasticSearch", it still does search. So I have no clue where it is  
> grabbing the indexed data after I have completely deleted "elasticSearch".  
> Any suggestions?  
> Thanks
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearch-On-JAVA-API-tp3829957p3833388.html](http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearch-On-JAVA-API-tp3829957p3833388.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![samCougars](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@samCougars](https://discuss.elastic.co/u/samCougars)\
**Post date:** [March 20, 2012, 11:13pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021/5 "2012-03-20T23:13:20Z")

</div>

Once the indexes are created, I am doing  
client.admin().indices().prepareRefresh().execute().actionGet();

and it does flush.  
After I have deleted elasticSearch, I was still able to perform search. I have no clue where it is grabbing data for this search. I have killed my JVM too and it still does search without elasticSearch being existed anywhere. So I ended up restarting the machine. With no elasticSearch folder and restart of my machine, it did not do a search. This makes me believe that the index is also stored somewhere in the memory with my settings. Here is my settings for a reference:  
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();  
settings.put("path.home",System.getProperty("user.home")+"/elasticSearch");  
settings.put("number\_of\_shards",1);  
settings.put("number\_of\_replicas",0);  
Node node = NodeBuilder.nodeBuilder().settings(settings).clusterName("firstCluster").node();

Client client = node.client();  
client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();

client.prepareIndex("searchdata", "exhibitor", "9999").setSource("My data information").execute().actionGet();

How do I prevent it NOT to be stored in memory? I want indexes to be stored ONLY in my disk location that I have provided under "setttings.put("path.home", System.getProperty("user.home")+"/elasticSearch")";

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [March 21, 2012, 5:29am UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021/6 "2012-03-21T05:29:56Z")

</div>

Hi,

based on your description it should be able to situate it using curl  
command. Can you prepare complete recreation script then?

Regards,  
Lukas

On Wed, Mar 21, 2012 at 12:13 AM, samCougars [sbaniya@gmail.com](mailto:sbaniya@gmail.com) wrote:

> Once the indexes are created, I am doing  
> client.admin().indices().prepareRefresh().execute().actionGet();
> 
> and it does flush.  
> After I have deleted elasticSearch, I was still able to perform search. I  
> have no clue where it is grabbing data for this search. I have killed my  
> JVM  
> too and it still does search without elasticSearch being existed anywhere.  
> So I ended up restarting the machine. With no elasticSearch folder and  
> restart of my machine, it did not do a search. This makes me believe that  
> the index is also stored somewhere in the memory with my settings. Here is  
> my settings for a reference:  
> ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();  
> settings.put("path.home",System.getProperty("user.home")+"/elasticSearch");  
> settings.put("number\_of\_shards",1);  
> settings.put("number\_of\_replicas",0);  
> Node node =
> 
> NodeBuilder.nodeBuilder().settings(settings).clusterName("firstCluster").node();
> 
> Client client = node.client();
> 
> client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
> 
> client.prepareIndex("searchdata", "exhibitor", "9999").setSource("My data  
> information").execute().actionGet();
> 
> How do I prevent it NOT to be stored in memory? I want indexes to be stored  
> ONLY in my disk location that I have provided under  
> "setttings.put("path.home",  
> System.getProperty("user.home")+"/elasticSearch")";
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearch-On-JAVA-API-tp3829957p3844082.html](http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearch-On-JAVA-API-tp3829957p3844082.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Satish1](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@Satish1](https://discuss.elastic.co/u/Satish1)\
**Post date:** [March 21, 2012, 3:58pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021/7 "2012-03-21T15:58:27Z")

</div>

What is a recreation script? I'm doing this as embedded project on  
webapp...

On Mar 20, 11:29 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:

> Hi,
> 
> based on your description it should be able to situate it using curl  
> command. Can you prepare complete recreation script then?
> 
> Regards,  
> Lukas
> 
> On Wed, Mar 21, 2012 at 12:13 AM, samCougars [sban...@gmail.com](mailto:sban...@gmail.com) wrote:
> 
> > Once the indexes are created, I am doing  
> > client.admin().indices().prepareRefresh().execute().actionGet();
> 
> > and it does flush.  
> > After I have deleted elasticSearch, I was still able to perform search. I  
> > have no clue where it is grabbing data for this search. I have killed my  
> > JVM  
> > too and it still does search without elasticSearch being existed anywhere.  
> > So I ended up restarting the machine. With no elasticSearch folder and  
> > restart of my machine, it did not do a search. This makes me believe that  
> > the index is also stored somewhere in the memory with my settings. Here is  
> > my settings for a reference:  
> > ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();  
> > settings.put("path.home",System.getProperty("user.home")+"/elasticSearch");  
> > settings.put("number\_of\_shards",1);  
> > settings.put("number\_of\_replicas",0);  
> > Node node =
> 
> > NodeBuilder.nodeBuilder().settings(settings).clusterName("firstCluster").no de();
> 
> > Client client = node.client();
> 
> > client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute() .actionGet();
> 
> > client.prepareIndex("searchdata", "exhibitor", "9999").setSource("My data  
> > information").execute().actionGet();
> 
> > How do I prevent it NOT to be stored in memory? I want indexes to be stored  
> > ONLY in my disk location that I have provided under  
> > "setttings.put("path.home",  
> > System.getProperty("user.home")+"/elasticSearch")";
> 
> > --  
> > View this message in context:  
> > [http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearc](http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearc)...  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [March 21, 2012, 4:38pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021/8 "2012-03-21T16:38:04Z")

</div>

See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help/) regarding recreation script.  
In other words, put together sequence of shell commands that demonstrate  
your use case and can be used by anybody to simulate/recreate the issue, it  
sounds like in your case it would be mostly 'curl' and 'rm' commands.

Regards,  
Lukas

On Wed, Mar 21, 2012 at 4:58 PM, Satish [satish.baniya@gmail.com](mailto:satish.baniya@gmail.com) wrote:

> What is a recreation script? I'm doing this as embedded project on  
> webapp...
> 
> On Mar 20, 11:29 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:
> 
> > Hi,
> > 
> > based on your description it should be able to situate it using curl  
> > command. Can you prepare complete recreation script then?
> > 
> > Regards,  
> > Lukas
> > 
> > On Wed, Mar 21, 2012 at 12:13 AM, samCougars [sban...@gmail.com](mailto:sban...@gmail.com) wrote:
> > 
> > > Once the indexes are created, I am doing  
> > > client.admin().indices().prepareRefresh().execute().actionGet();
> > 
> > > and it does flush.  
> > > After I have deleted elasticSearch, I was still able to perform  
> > > search. I  
> > > have no clue where it is grabbing data for this search. I have killed  
> > > my  
> > > JVM  
> > > too and it still does search without elasticSearch being existed  
> > > anywhere.  
> > > So I ended up restarting the machine. With no elasticSearch folder and  
> > > restart of my machine, it did not do a search. This makes me believe  
> > > that  
> > > the index is also stored somewhere in the memory with my settings.  
> > > Here is  
> > > my settings for a reference:  
> > > ImmutableSettings.Builder settings =  
> > > ImmutableSettings.settingsBuilder();
> 
> settings.put("path.home",System.getProperty("user.home")+"/elasticSearch");
> 
> > > settings.put("number\_of\_shards",1);  
> > > settings.put("number\_of\_replicas",0);  
> > > Node node =
> > 
> > >
> 
> NodeBuilder.nodeBuilder().settings(settings).clusterName("firstCluster").no  
> de();
> 
> > > Client client = node.client();
> > 
> > >
> 
> client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute()  
> .actionGet();
> 
> > > client.prepareIndex("searchdata", "exhibitor", "9999").setSource("My  
> > > data  
> > > information").execute().actionGet();
> > 
> > > How do I prevent it NOT to be stored in memory? I want indexes to be  
> > > stored  
> > > ONLY in my disk location that I have provided under  
> > > "setttings.put("path.home",  
> > > System.getProperty("user.home")+"/elasticSearch")";
> > 
> > > --  
> > > View this message in context:  
> > > [http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearc](http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearc).  
> > > ..  
> > > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![samCougars](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@samCougars](https://discuss.elastic.co/u/samCougars)\
**Post date:** [March 21, 2012, 4:54pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021/9 "2012-03-21T16:54:30Z")

</div>

What is a recreation script?

---

<div class="post-metadata">

**Author:** ![Satish1](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@Satish1](https://discuss.elastic.co/u/Satish1)\
**Post date:** [March 21, 2012, 9:10pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021/10 "2012-03-21T21:10:44Z")

</div>

I have upgraded to elasticSearch 0.19.1 and it seemed to fix the  
problem for now. If I remove elasticSearch data folder, it does NOT do  
the search anymore.  
Thanks,  
Satish

On Mar 21, 10:38 am, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:

> Seehttp://www.elasticsearch.org/help/regarding recreation script.  
> In other words, put together sequence of shell commands that demonstrate  
> your use case and can be used by anybody to simulate/recreate the issue, it  
> sounds like in your case it would be mostly 'curl' and 'rm' commands.
> 
> Regards,  
> Lukas
> 
> On Wed, Mar 21, 2012 at 4:58 PM, Satish [satish.ban...@gmail.com](mailto:satish.ban...@gmail.com) wrote:
> 
> > What is a recreation script? I'm doing this as embedded project on  
> > webapp...
> 
> > On Mar 20, 11:29 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:
> > 
> > > Hi,
> 
> > > based on your description it should be able to situate it using curl  
> > > command. Can you prepare complete recreation script then?
> 
> > > Regards,  
> > > Lukas
> 
> > > On Wed, Mar 21, 2012 at 12:13 AM, samCougars [sban...@gmail.com](mailto:sban...@gmail.com) wrote:
> > > 
> > > > Once the indexes are created, I am doing  
> > > > client.admin().indices().prepareRefresh().execute().actionGet();
> 
> > > > and it does flush.  
> > > > After I have deleted elasticSearch, I was still able to perform  
> > > > search. I  
> > > > have no clue where it is grabbing data for this search. I have killed  
> > > > my  
> > > > JVM  
> > > > too and it still does search without elasticSearch being existed  
> > > > anywhere.  
> > > > So I ended up restarting the machine. With no elasticSearch folder and  
> > > > restart of my machine, it did not do a search. This makes me believe  
> > > > that  
> > > > the index is also stored somewhere in the memory with my settings.  
> > > > Here is  
> > > > my settings for a reference:  
> > > > ImmutableSettings.Builder settings =  
> > > > ImmutableSettings.settingsBuilder();
> 
> > settings.put("path.home",System.getProperty("user.home")+"/elasticSearch");
> > 
> > > > settings.put("number\_of\_shards",1);  
> > > > settings.put("number\_of\_replicas",0);  
> > > > Node node =
> 
> > NodeBuilder.nodeBuilder().settings(settings).clusterName("firstCluster").no  
> > de();
> 
> > > > Client client = node.client();
> 
> > client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute()  
> > .actionGet();
> 
> > > > client.prepareIndex("searchdata", "exhibitor", "9999").setSource("My  
> > > > data  
> > > > information").execute().actionGet();
> 
> > > > How do I prevent it NOT to be stored in memory? I want indexes to be  
> > > > stored  
> > > > ONLY in my disk location that I have provided under  
> > > > "setttings.put("path.home",  
> > > > System.getProperty("user.home")+"/elasticSearch")";
> 
> > > > --  
> > > > View this message in context:  
> > > > [http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearc](http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearc).  
> > > > ..  
> > > > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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, 3:35am UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java-api/7021/11 "2017-07-06T03:35:16Z")

</div>


