# Java API and controlling node data directory

**URL:** <https://discuss.elastic.co/t/java-api-and-controlling-node-data-directory/3662>\
**Category:** Elasticsearch\
**Created:** [December 14, 2010, 4:05pm UTC](https://discuss.elastic.co/t/java-api-and-controlling-node-data-directory/3662 "2010-12-14T16:05:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wojciech\_Durczynski](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wojciech\_Durczynski](https://discuss.elastic.co/u/Wojciech_Durczynski)\
**Post date:** [December 14, 2010, 4:05pm UTC](https://discuss.elastic.co/t/java-api-and-controlling-node-data-directory/3662/1 "2010-12-14T16:05:03Z")

</div>

Hello.

I'm using Elastic Search Java API so that Elastic Search nodes can be  
embedded in my application.  
And I have some questions:

1. How to change default data directory, where node stores its data?  
It is always created in current working directory as "data". Is there  
a setting to control this behaviour?
2. How to disable gateway/translogs/data storing completely (using  
java API), so that Elastic Search won't create any directories on hard  
drive and keep everything in memory only?
3. Is there a possibility of defining recursive data mapping? I'd like  
to store in index an object, which can contain other objects of the  
same type as properties, and they also can contain these objects as  
properties etc.

Regards  
Wojciech Durczyński

---

<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:** [December 15, 2010, 4:06am UTC](https://discuss.elastic.co/t/java-api-and-controlling-node-data-directory/3662/2 "2010-12-15T04:06:57Z")

</div>

In general, to further configure ES when embedded in Java App is either by passing settings programmatically to the NodeBuilder, or having an elasticsearch.(yml|json) configuration within the classpath under / or /config.

1. In order to change the data directory location, set the `path.data` setting to the location you want it to be stored at.

2. In order to have the index be stored in memory (and not survive restarts), set `index.store.type` to `memory`.

3. You can define template mappings.  
On Tuesday, December 14, 2010 at 6:05 PM, Wojciech DurczyÅski wrote:

> Hello.
> 
> I'm using Elastic Search Java API so that Elastic Search nodes can be  
> embedded in my application.  
> And I have some questions:
> 
> 1. How to change default data directory, where node stores its data?  
> It is always created in current working directory as "data". Is there  
> a setting to control this behaviour?
> 2. How to disable gateway/translogs/data storing completely (using  
> java API), so that Elastic Search won't create any directories on hard  
> drive and keep everything in memory only?
> 3. Is there a possibility of defining recursive data mapping? I'd like  
> to store in index an object, which can contain other objects of the  
> same type as properties, and they also can contain these objects as  
> properties etc.
> 
> Regards  
> Wojciech DurczyÅski

---

<div class="post-metadata">

**Author:** ![Wojciech\_Durczynski](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wojciech\_Durczynski](https://discuss.elastic.co/u/Wojciech_Durczynski)\
**Post date:** [December 15, 2010, 4:54pm UTC](https://discuss.elastic.co/t/java-api-and-controlling-node-data-directory/3662/3 "2010-12-15T16:54:36Z")

</div>

Thank you for quick answer.

I set "index.store.type" to "memory" in context of whole node and  
additionally during creation of particular index.  
And the problem is that directories are still created, and they  
contain files translog-\* and node.lock.  
Is there a possibility to disable creation of those files also?

I set also "gateway.type" to "none" and sometimes despite of this  
setting (and index.store.type=memory) I have an exception:  
org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [1/  
not recovered from gateway];  
at  
org.elasticsearch.cluster.block.ClusterBlocks.indexBlockedRaiseException(ClusterBlocks.java:  
112)  
at  
org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction.checkBlock(TransportCreateIndexAction.java:  
65)  
at  
org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction.checkBlock(TransportCreateIndexAction.java:  
42)  
at  
org.elasticsearch.action.support.master.TransportMasterNodeOperationAction  
$1.run(TransportMasterNodeOperationAction.java:91)  
at java.util.concurrent.ThreadPoolExecutor  
$Worker.runTask(ThreadPoolExecutor.java:886)  
at java.util.concurrent.ThreadPoolExecutor  
$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:619)

On Dec 15, 5:06 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> In general, to further configure ES when embedded in Java App is either by passing settings programmatically to the NodeBuilder, or having an elasticsearch.(yml|json) configuration within the classpath under / or /config.
> 
> 1. In order to change the data directory location, set the `path.data` setting to the location you want it to be stored at.
> 
> 2. In order to have the index be stored in memory (and not survive restarts), set `index.store.type` to `memory`.
> 
> 3. You can define template mappings.
> 
> On Tuesday, December 14, 2010 at 6:05 PM, Wojciech Durczyński wrote:
> 
> > Hello.
> 
> > I'm using Elastic Search Java API so that Elastic Search nodes can be  
> > embedded in my application.  
> > And I have some questions:
> > 
> > 1. How to change default data directory, where node stores its data?  
> > It is always created in current working directory as "data". Is there  
> > a setting to control this behaviour?
> > 2. How to disable gateway/translogs/data storing completely (using  
> > java API), so that Elastic Search won't create any directories on hard  
> > drive and keep everything in memory only?
> > 3. Is there a possibility of defining recursive data mapping? I'd like  
> > to store in index an object, which can contain other objects of the  
> > same type as properties, and they also can contain these objects as  
> > properties etc.
> 
> > Regards  
> > Wojciech Durczyński

---

<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:** [December 15, 2010, 5:43pm UTC](https://discuss.elastic.co/t/java-api-and-controlling-node-data-directory/3662/4 "2010-12-15T17:43:39Z")

</div>

No, those files will always get created.

2010/12/15 Wojciech Durczyński [wojciech.durczynski@comarch.com](mailto:wojciech.durczynski@comarch.com)

> Thank you for quick answer.
> 
> I set "index.store.type" to "memory" in context of whole node and  
> additionally during creation of particular index.  
> And the problem is that directories are still created, and they  
> contain files translog-\* and node.lock.  
> Is there a possibility to disable creation of those files also?
> 
> I set also "gateway.type" to "none" and sometimes despite of this  
> setting (and index.store.type=memory) I have an exception:  
> org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [1/  
> not recovered from gateway];  
> at
> 
> org.elasticsearch.cluster.block.ClusterBlocks.indexBlockedRaiseException(ClusterBlocks.java:  
> 112)  
> at
> 
> org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction.checkBlock(TransportCreateIndexAction.java:  
> 65)  
> at
> 
> org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction.checkBlock(TransportCreateIndexAction.java:  
> 42)  
> at  
> org.elasticsearch.action.support.master.TransportMasterNodeOperationAction  
> $1.run(TransportMasterNodeOperationAction.java:91)  
> at java.util.concurrent.ThreadPoolExecutor  
> $Worker.runTask(ThreadPoolExecutor.java:886)  
> at java.util.concurrent.ThreadPoolExecutor  
> $Worker.run(ThreadPoolExecutor.java:908)  
> at java.lang.Thread.run(Thread.java:619)
> 
> On Dec 15, 5:06 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > In general, to further configure ES when embedded in Java App is either  
> > by passing settings programmatically to the NodeBuilder, or having an  
> > elasticsearch.(yml|json) configuration within the classpath under / or  
> > /config.
> > 
> > 1. In order to change the data directory location, set the `path.data`  
> > setting to the location you want it to be stored at.
> > 
> > 2. In order to have the index be stored in memory (and not survive  
> > restarts), set `index.store.type` to `memory`.
> > 
> > 3. You can define template mappings.
> > 
> > On Tuesday, December 14, 2010 at 6:05 PM, Wojciech Durczyński wrote:
> > 
> > > Hello.
> > 
> > > I'm using Elastic Search Java API so that Elastic Search nodes can be  
> > > embedded in my application.  
> > > And I have some questions:
> > > 
> > > 1. How to change default data directory, where node stores its data?  
> > > It is always created in current working directory as "data". Is there  
> > > a setting to control this behaviour?
> > > 2. How to disable gateway/translogs/data storing completely (using  
> > > java API), so that Elastic Search won't create any directories on hard  
> > > drive and keep everything in memory only?
> > > 3. Is there a possibility of defining recursive data mapping? I'd like  
> > > to store in index an object, which can contain other objects of the  
> > > same type as properties, and they also can contain these objects as  
> > > properties etc.
> > 
> > > Regards  
> > > Wojciech Durczyński

---

<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, 4:15am UTC](https://discuss.elastic.co/t/java-api-and-controlling-node-data-directory/3662/5 "2017-07-06T04:15:16Z")

</div>


