# Java API

**URL:** <https://discuss.elastic.co/t/java-api/7619>\
**Category:** Elasticsearch\
**Created:** [May 9, 2012, 4:44pm UTC](https://discuss.elastic.co/t/java-api/7619 "2012-05-09T16:44:03Z")\
**Posts on this page:** 7\
**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:** [May 9, 2012, 4:44pm UTC](https://discuss.elastic.co/t/java-api/7619/1 "2012-05-09T16:44:03Z")

</div>

I'm using JAVA api for ES. I am creating index with this command:  
client.prepareIndex("myEventSpecific", "myObject", "myID").setSource("myJsonText").execute().actionGet();

On my home directory, I see "searchdata" folder even I have specified to use "myEventSpecific". So I see both "myEventSpecific" and "searchdata" folders inside my indices folder. Do you know why it creates "searchdata" folder?  
This is how my folder structure is:  
1.myhomeDirectory/data/myEventSpecific/nodes/0/indices/myEventSpecific  
2.myhomeDirectory/data/myEventSpecific/nodes/0/indices/searchdata

---

<div class="post-metadata">

**Author:** ![Eric\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_jain/32/834_2.png) [@Eric\_Jain](https://discuss.elastic.co/u/Eric_Jain)\
**Post date:** [May 9, 2012, 4:57pm UTC](https://discuss.elastic.co/t/java-api/7619/2 "2012-05-09T16:57:36Z")

</div>

On May 9, 9:44 am, samCougars [sban...@gmail.com](mailto:sban...@gmail.com) wrote:

> This is how my folder structure is:  
> 1.myhomeDirectory/data/myEventSpecific/nodes/0/indices/myEventSpecific  
> 2.myhomeDirectory/data/myEventSpecific/nodes/0/indices/searchdata

I've never seen a "searchdata" folder. If you delete it, is it  
recreated?

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [May 9, 2012, 5:08pm UTC](https://discuss.elastic.co/t/java-api/7619/3 "2012-05-09T17:08:26Z")

</div>

I suspect it is not the code you pasted, but your client.

Which client are you creating: a NodeClient or TransportClient? How  
are you creating the client? Are you setting node.client = true?

--  
Ivan

On Wed, May 9, 2012 at 9:44 AM, samCougars [sbaniya@gmail.com](mailto:sbaniya@gmail.com) wrote:

> I'm using JAVA api for ES. I am creating index with this command:  
> client.prepareIndex("myEventSpecific", "myObject",  
> "myID").setSource("myJsonText").execute().actionGet();
> 
> On my home directory, I see "searchdata" folder even I have specified to use  
> "myEventSpecific". So I see both "myEventSpecific" and "searchdata" folders  
> inside my indices folder. Do you know why it creates "searchdata" folder?  
> This is how my folder structure is:  
> 1.myhomeDirectory/data/myEventSpecific/nodes/0/indices/myEventSpecific  
> 2.myhomeDirectory/data/myEventSpecific/nodes/0/indices/searchdata
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Java-API-tp3974683.html](http://elasticsearch-users.115913.n3.nabble.com/Java-API-tp3974683.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:** [May 9, 2012, 8:49pm UTC](https://discuss.elastic.co/t/java-api/7619/4 "2012-05-09T20:49:11Z")

</div>

yes, once I delete the folder it still creates searchData folder...

---

<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:** [May 9, 2012, 8:55pm UTC](https://discuss.elastic.co/t/java-api/7619/5 "2012-05-09T20:55:24Z")

</div>

I'm creating a Node Client. First I create a node then get the client from node as follows:  
Client client = null;  
try{  
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();  
String eventSpecific = "myEventSpecific";  
settings.put("path.home",System.getProperty("user.home")+"/elasticSearch"+eventSpecific);  
settings.put("number\_of\_shards",1);  
settings.put("number\_of\_replicas",0);  
indexCreatingNode = NodeBuilder.nodeBuilder().settings(settings).clusterName(eventSpecific).node();

```
 // start a node
 indexCreatingNode.start();
 // INDEX my required fields
 
 // once all my fields are indexed then 
  client = indexCreatingNode.client();
  client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();

```

}  
catch (Exception ex)  
{  
log.error(ex);  
}  
finally  
{  
if (client != null)  
client.close();  
if (indexCreatingNode != null)  
{  
indexCreatingNode.stop();  
indexCreatingNode.close();  
}  
}

---

<div class="post-metadata">

**Author:** ![Eric\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_jain/32/834_2.png) [@Eric\_Jain](https://discuss.elastic.co/u/Eric_Jain)\
**Post date:** [May 9, 2012, 10:09pm UTC](https://discuss.elastic.co/t/java-api/7619/6 "2012-05-09T22:09:10Z")

</div>

I just ran this code, and all I get is an empty dir:  
$HOME/elasticSearchmyEventSpecific/data/myEventSpecific/nodes/0.

On Wed, May 9, 2012 at 1:55 PM, samCougars [sbaniya@gmail.com](mailto:sbaniya@gmail.com) wrote:

> I'm creating a Node Client. First I create a node then get the client from  
> node as follows:  
> Client client = null;  
> try{  
> ImmutableSettings.Builder settings =  
> ImmutableSettings.settingsBuilder();  
> String eventSpecific = "myEventSpecific";
> 
> settings.put("path.home",System.getProperty("user.home")+"/elasticSearch"+eventSpecific);  
> settings.put("number\_of\_shards",1);  
> settings.put("number\_of\_replicas",0);  
> indexCreatingNode =  
> NodeBuilder.nodeBuilder().settings(settings).clusterName(eventSpecific).node();
> 
> ```
> // start a node
> indexCreatingNode.start();
> // INDEX my required fields
> 
> // once all my fields are indexed then
> client = indexCreatingNode.client();
> 
> ```
> 
> client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();  
> }  
> catch (Exception ex)  
> {  
> log.error(ex);  
> }  
> finally  
> {  
> if (client != null)  
> client.close();  
> if (indexCreatingNode != null)  
> {  
> indexCreatingNode.stop();  
> indexCreatingNode.close();  
> }  
> }
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Java-API-tp3974683p3975368.html](http://elasticsearch-users.115913.n3.nabble.com/Java-API-tp3974683p3975368.html)  
> 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:29am UTC](https://discuss.elastic.co/t/java-api/7619/7 "2017-07-06T03:29:33Z")

</div>


