# Help with Simple Program

**URL:** <https://discuss.elastic.co/t/help-with-simple-program/8260>\
**Category:** Elasticsearch\
**Created:** [June 29, 2012, 1:01pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260 "2012-06-29T13:01:52Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bahubali\_Jain](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@Bahubali\_Jain](https://discuss.elastic.co/u/Bahubali_Jain)\
**Post date:** [June 29, 2012, 1:01pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/1 "2012-06-29T13:01:52Z")

</div>

Hi,  
Below is a sample program to index some content to the ES running in  
localhost on 9200.But I dont see this indexing the content, I dont see the  
testtweet folder being created in the data folder.I am trying this in  
windows.

public class Main {  
public static void main(String[] args) {  
Node node = NodeBuilder.nodeBuilder().node().start();

```
    Client client = node.client ();

    try {
        IndexResponse response = client
                .prepareIndex("testtweet", "tweet1", "0")
                .setSource(
                        jsonBuilder()
                                .startObject()
                                .field("user", "kimchy")
                                .field("postDate", new Date())
                                .field("message",
                                        "trying out Elastic Search")
                                .endObject()).execute().actionGet();
        System.out.println("Done");
    } catch (ElasticSearchException e) {

        e.printStackTrace();
    } catch (IOException e) {

        e.printStackTrace();
    }

    node.close();

}

```

}

---

<div class="post-metadata">

**Author:** ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)\
**Post date:** [June 29, 2012, 1:10pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/2 "2012-06-29T13:10:37Z")

</div>

Hello!

I think you are starting a new node, instead of connecting to your instance. Try the following:

Client client = NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();

Instead of your:

"

Node node = NodeBuilder.nodeBuilder().node().start();

Client client = node.client ();

"

Please notice that you need to provide a cluster name.

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

Hi,

Below is a sample program to index some content to the ES running in localhost on 9200.But I dont see this indexing the content, I dont see the testtweet folder being created in the data folder.I am trying this in windows.

public class Main {

```
public static void main(String[] args) {

    Node node = NodeBuilder.nodeBuilder().node().start();

    

    Client client = node.client ();

    

    try {

        IndexResponse response = client

                .prepareIndex("testtweet", "tweet1", "0")

                .setSource(

                        jsonBuilder()

                                .startObject()

                                .field("user", "kimchy")

                                .field("postDate", new Date())

                                .field("message",

                                        "trying out Elastic Search")

                                .endObject()).execute().actionGet();

        System.out.println("Done");

    } catch (ElasticSearchException e) {

        e.printStackTrace();

    } catch (IOException e) {

        e.printStackTrace();

    }

    node.close();

}

```

}

---

<div class="post-metadata">

**Author:** ![Bahubali\_Jain](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@Bahubali\_Jain](https://discuss.elastic.co/u/Bahubali_Jain)\
**Post date:** [June 29, 2012, 1:38pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/3 "2012-06-29T13:38:26Z")

</div>

Hi Rafał,  
I get the exception \*  
org.elasticsearch.discovery.MasterNotDiscoveredException\*: .  
I set the clustername to "elasticsearch" (In elasticsearch.yml the  
cluster.name is set to elasticsearch.)

Thanks,  
Baahu

On Fri, Jun 29, 2012 at 6:40 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:

> Hello!
> 
> I think you are starting a new node, instead of connecting to your  
> instance. Try the following:
> 
> Client client =  
> NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();
> 
> Instead of your:
> 
> "  
> Node node = NodeBuilder.nodeBuilder().node().start();
> 
> Client client = node.client ();  
> "
> 
> Please notice that you need to provide a cluster name.
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch -  
> Elasticsearch
> 
> - 
> 
> Hi,  
> Below is a sample program to index some content to the ES running in  
> localhost on 9200.But I dont see this indexing the content, I dont see the  
> testtweet folder being created in the data folder.I am trying this in  
> windows.
> 
> public class Main {  
> public static void main(String args) {  
> Node node = NodeBuilder.nodeBuilder().node().start();
> 
> ```
> Client client = node.client ();
> 
> try {
> IndexResponse response = client
> .prepareIndex("testtweet", "tweet1", "0")
> .setSource(
> jsonBuilder()
> .startObject()
> .field("user", "kimchy")
> .field("postDate", new Date())
> .field("message",
> "trying out Elastic Search")
> .endObject()).execute().actionGet();
> System.out.println("Done");
> } catch (ElasticSearchException e) {
> 
> e.printStackTrace();
> } catch (IOException e) {
> 
> e.printStackTrace();
> }
> 
> node.close();
> 
> }
> 
> ```
> 
> }

--  
Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)

---

<div class="post-metadata">

**Author:** ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)\
**Post date:** [June 29, 2012, 1:44pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/4 "2012-06-29T13:44:35Z")

</div>

Hello!

Can you try connecting with the TransportClient. This code should do the work:

TransportClient client = new TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch").build());

client.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

Hi Rafał,

I get the exception **org.elasticsearch.discovery.MasterNotDiscoveredException** : .

I set the clustername to "elasticsearch" (In elasticsearch.yml the [cluster.name](http://cluster.name) is set to elasticsearch.)

Thanks,

Baahu

On Fri, Jun 29, 2012 at 6:40 PM, Rafał Kuć \<[r.kuc@solr.pl](mailto:r.kuc@solr.pl)\> wrote:

Hello!

I think you are starting a new node, instead of connecting to your instance. Try the following:

Client client = NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();

Instead of your:

"

Node node = NodeBuilder.nodeBuilder().node().start();

Client client = node.client ();

"

Please notice that you need to provide a cluster name.

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

Hi,

Below is a sample program to index some content to the ES running in localhost on 9200.But I dont see this indexing the content, I dont see the testtweet folder being created in the data folder.I am trying this in windows.

public class Main {

```
public static void main(String[] args) {

    Node node = NodeBuilder.nodeBuilder().node().start();

    

    Client client = node.client ();

    

    try {

        IndexResponse response = client

                .prepareIndex("testtweet", "tweet1", "0")

                .setSource(

                        jsonBuilder()

                                .startObject()

                                .field("user", "kimchy")

                                .field("postDate", new Date())

                                .field("message",

                                        "trying out Elastic Search")

                                .endObject()).execute().actionGet();

        System.out.println("Done");

    } catch (ElasticSearchException e) {

        e.printStackTrace();

    } catch (IOException e) {

        e.printStackTrace();

    }

    node.close();

}

```

}

--

Twitter:[http://](http://twitter.com/Baahu)[twitter](http://twitter.com/Baahu)[.com/Baahu](http://twitter.com/Baahu)

---

<div class="post-metadata">

**Author:** ![Bahubali\_Jain](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@Bahubali\_Jain](https://discuss.elastic.co/u/Bahubali_Jain)\
**Post date:** [June 29, 2012, 1:53pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/5 "2012-06-29T13:53:32Z")

</div>

Hi Rafal,  
Now I get "org.elasticsearch.client.transport.NoNodeAvailableException" ☹

I dont see any problems while indexing contents thru cURL...

Thanks,  
Baahu

On Fri, Jun 29, 2012 at 7:14 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:

> Hello!
> 
> Can you try connecting with the TransportClient. This code should do the  
> work:
> 
> TransportClient client = new  
> TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name",  
> "elasticsearch").build());  
> client.addTransportAddress(new InetSocketTransportAddress("localhost",  
> 9300));
> 
> _--  
> Regards,  
> Rafał Kuć  
> Sematext :: \*  
> [http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch - Elasticsearch
> 
> - 
> 
> Hi Rafał,  
> I get the exception \*  
> org.elasticsearch.discovery.MasterNotDiscoveredException\*: .  
> I set the clustername to "elasticsearch" (In elasticsearch.yml the  
> cluster.name is set to elasticsearch.)
> 
> Thanks,  
> Baahu
> 
> On Fri, Jun 29, 2012 at 6:40 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> I think you are starting a new node, instead of connecting to your  
> instance. Try the following:
> 
> Client client =  
> NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();
> 
> Instead of your:
> 
> "  
> Node node = NodeBuilder.nodeBuilder().node().start();
> 
> Client client = node.client ();  
> "
> 
> Please notice that you need to provide a cluster name.
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch -  
> Elasticsearch
> 
> - 
> 
> Hi,  
> Below is a sample program to index some content to the ES running in  
> localhost on 9200.But I dont see this indexing the content, I dont see the  
> testtweet folder being created in the data folder.I am trying this in  
> windows.
> 
> public class Main {  
> public static void main(String args) {  
> Node node = NodeBuilder.nodeBuilder().node().start();
> 
> ```
> Client client = node.client ();
> 
> try {
> IndexResponse response = client
> .prepareIndex("testtweet", "tweet1", "0")
> .setSource(
> jsonBuilder()
> .startObject()
> .field("user", "kimchy")
> .field("postDate", new Date())
> .field("message",
> "trying out Elastic Search")
> .endObject()).execute().actionGet();
> System.out.println("Done");
> } catch (ElasticSearchException e) {
> 
> e.printStackTrace();
> } catch (IOException e) {
> 
> e.printStackTrace();
> }
> 
> node.close();
> 
> }
> 
> ```
> 
> }
> 
> --  
> Twitter:http:// [http://twitter.com/Baahu](http://twitter.com/Baahu)twitter[http://twitter.com/Baahu](http://twitter.com/Baahu)  
> .com/Baahu [http://twitter.com/Baahu](http://twitter.com/Baahu)

--  
Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)

---

<div class="post-metadata">

**Author:** ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)\
**Post date:** [June 29, 2012, 2:04pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/6 "2012-06-29T14:04:42Z")

</div>

Hello!

This usually means that the client can't connect to the cluster. Could you post the code ?

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

Hi Rafal,

Now I get "org.elasticsearch.client.transport.NoNodeAvailableException" ☹

I dont see any problems while indexing contents thru cURL...

Thanks,

Baahu

On Fri, Jun 29, 2012 at 7:14 PM, Rafał Kuć \<[r.kuc@solr.pl](mailto:r.kuc@solr.pl)\> wrote:

Hello!

Can you try connecting with the TransportClient. This code should do the work:

TransportClient client = new TransportClient(ImmutableSettings.settingsBuilder().put("[cluster.name](http://cluster.name)", "elasticsearch").build());

client.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));

_--_

Regards,

Rafał Kuć

Sematext ::

[http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

Hi Rafał,

I get the exception **org.elasticsearch.discovery.MasterNotDiscoveredException** : .

I set the clustername to "elasticsearch" (In elasticsearch.yml the [cluster.name](http://cluster.name) is set to elasticsearch.)

Thanks,

Baahu

On Fri, Jun 29, 2012 at 6:40 PM, Rafał Kuć \<[r.kuc@solr.pl](mailto:r.kuc@solr.pl)\> wrote:

Hello!

I think you are starting a new node, instead of connecting to your instance. Try the following:

Client client = NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();

Instead of your:

"

Node node = NodeBuilder.nodeBuilder().node().start();

Client client = node.client ();

"

Please notice that you need to provide a cluster name.

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

Hi,

Below is a sample program to index some content to the ES running in localhost on 9200.But I dont see this indexing the content, I dont see the testtweet folder being created in the data folder.I am trying this in windows.

public class Main {

```
public static void main(String[] args) {

    Node node = NodeBuilder.nodeBuilder().node().start();

    

    Client client = node.client ();

    

    try {

        IndexResponse response = client

                .prepareIndex("testtweet", "tweet1", "0")

                .setSource(

                        jsonBuilder()

                                .startObject()

                                .field("user", "kimchy")

                                .field("postDate", new Date())

                                .field("message",

                                        "trying out Elastic Search")

                                .endObject()).execute().actionGet();

        System.out.println("Done");

    } catch (ElasticSearchException e) {

        e.printStackTrace();

    } catch (IOException e) {

        e.printStackTrace();

    }

    node.close();

}

```

}

--

Twitter:[http://](http://twitter.com/Baahu)[twitter](http://twitter.com/Baahu)[.com/Baahu](http://twitter.com/Baahu)

--

Twitter:[http://](http://twitter.com/Baahu)[twitter](http://twitter.com/Baahu)[.com/Baahu](http://twitter.com/Baahu)

---

<div class="post-metadata">

**Author:** ![Bahubali\_Jain](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@Bahubali\_Jain](https://discuss.elastic.co/u/Bahubali_Jain)\
**Post date:** [June 29, 2012, 2:07pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/7 "2012-06-29T14:07:56Z")

</div>

Hi Rafal,

Here you go..

import static org.elasticsearch.node.NodeBuilder._;  
import static org.elasticsearch.common.xcontent.XContentFactory._;

import java.io.IOException;  
import java.util.Date;

import org.elasticsearch.ElasticSearchException;  
import org.elasticsearch.action.index.IndexResponse;  
import org.elasticsearch.client.Client;  
import org.elasticsearch.client.transport.TransportClient;  
import org.elasticsearch.common.settings.ImmutableSettings;  
import org.elasticsearch.common.settings.Settings;  
import org.elasticsearch.common.transport.InetSocketTransportAddress;  
import org.elasticsearch.node.Node;  
import org.elasticsearch.node.NodeBuilder;  
public class Main {  
public static void main(String args) {

```
    TransportClient client = new

```

TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name",  
"elasticsearch").build());  
client.addTransportAddress(new  
InetSocketTransportAddress("localhost", 9300));

```
    try {
        IndexResponse response = client
                .prepareIndex("testtweet", "tweet1", "0")
                .setSource(
                        jsonBuilder()
                                .startObject()
                                .field("user", "kimchy")
                                .field("postDate", new Date())
                                .field("message",
                                        "trying out Elastic Search")
                                .endObject()).execute().actionGet();
        System.out.println("Done");
    } catch (ElasticSearchException e) {

        e.printStackTrace();
    } catch (IOException e) {

        e.printStackTrace();
    }

    //node.close();

}

```

}

On Fri, Jun 29, 2012 at 7:34 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:

> Hello!
> 
> This usually means that the client can't connect to the cluster. Could you  
> post the code ?
> 
> _--  
> Regards,  
> Rafał Kuć  
> Sematext :: \*  
> [http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch - Elasticsearch
> 
> - 
> 
> Hi Rafal,  
> Now I get "org.elasticsearch.client.transport.NoNodeAvailableException" ☹
> 
> I dont see any problems while indexing contents thru cURL...
> 
> Thanks,  
> Baahu
> 
> On Fri, Jun 29, 2012 at 7:14 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> Can you try connecting with the TransportClient. This code should do the  
> work:
> 
> TransportClient client = new  
> TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name",  
> "elasticsearch").build());  
> client.addTransportAddress(new InetSocketTransportAddress("localhost",  
> 9300));
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext ::  
> _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch - Elasticsearch
> 
> - 
> 
> Hi Rafał,  
> I get the exception \*  
> org.elasticsearch.discovery.MasterNotDiscoveredException\*: .  
> I set the clustername to "elasticsearch" (In elasticsearch.yml the  
> cluster.name is set to elasticsearch.)
> 
> Thanks,  
> Baahu
> 
> On Fri, Jun 29, 2012 at 6:40 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> I think you are starting a new node, instead of connecting to your  
> instance. Try the following:
> 
> Client client =  
> NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();
> 
> Instead of your:
> 
> "  
> Node node = NodeBuilder.nodeBuilder().node().start();
> 
> Client client = node.client ();  
> "
> 
> Please notice that you need to provide a cluster name.
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch -  
> Elasticsearch
> 
> - 
> 
> Hi,  
> Below is a sample program to index some content to the ES running in  
> localhost on 9200.But I dont see this indexing the content, I dont see the  
> testtweet folder being created in the data folder.I am trying this in  
> windows.
> 
> public class Main {  
> public static void main(String args) {  
> Node node = NodeBuilder.nodeBuilder().node().start();
> 
> ```
> Client client = node.client ();
> 
> try {
> IndexResponse response = client
> .prepareIndex("testtweet", "tweet1", "0")
> .setSource(
> jsonBuilder()
> .startObject()
> .field("user", "kimchy")
> .field("postDate", new Date())
> .field("message",
> "trying out Elastic Search")
> .endObject()).execute().actionGet();
> System.out.println("Done");
> } catch (ElasticSearchException e) {
> 
> e.printStackTrace();
> } catch (IOException e) {
> 
> e.printStackTrace();
> }
> 
> node.close();
> 
> }
> 
> ```
> 
> }
> 
> --  
> Twitter:http:// [http://twitter.com/Baahu](http://twitter.com/Baahu)twitter[http://twitter.com/Baahu](http://twitter.com/Baahu)  
> .com/Baahu [http://twitter.com/Baahu](http://twitter.com/Baahu)
> 
> --  
> Twitter:http:// [http://twitter.com/Baahu](http://twitter.com/Baahu)twitter[http://twitter.com/Baahu](http://twitter.com/Baahu)  
> .com/Baahu [http://twitter.com/Baahu](http://twitter.com/Baahu)

--  
Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)

---

<div class="post-metadata">

**Author:** ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)\
**Post date:** [June 29, 2012, 2:33pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/8 "2012-06-29T14:33:28Z")

</div>

Hello!

Just tested your code with ES 0.19.4 - no problem with connecting to my local instance with the code exactly copy pasted from your post.

Are you sure, your ElasticSearch instance listens on localhost ?

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

Hi Rafal,

Here you go..

import static org.elasticsearch.node.NodeBuilder.\*;

import static org.elasticsearch.common.xcontent.XContentFactory.\*;

import java.io.IOException;

import java.util.Date;

import org.elasticsearch.ElasticSearchException;

import org.elasticsearch.action.index.IndexResponse;

import org.elasticsearch.client.Client;

import org.elasticsearch.client.transport.TransportClient;

import org.elasticsearch.common.settings.ImmutableSettings;

import org.elasticsearch.common.settings.Settings;

import org.elasticsearch.common.transport.InetSocketTransportAddress;

import org.elasticsearch.node.Node;

import org.elasticsearch.node.NodeBuilder;

public class Main {

```
public static void main(String[] args) {

    TransportClient client = new TransportClient(ImmutableSettings.settingsBuilder().put("<a style=" font-family:'courier new'; font-size: 9pt;" href="http://cluster.name">cluster.name</a>", "elasticsearch").build());

    client.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));

            

    try {

        IndexResponse response = client

                .prepareIndex("testtweet", "tweet1", "0")

                .setSource(

                        jsonBuilder()

                                .startObject()

                                .field("user", "kimchy")

                                .field("postDate", new Date())

                                .field("message",

                                        "trying out Elastic Search")

                                .endObject()).execute().actionGet();

        System.out.println("Done");

    } catch (ElasticSearchException e) {

        e.printStackTrace();

    } catch (IOException e) {

        e.printStackTrace();

    }

    //node.close();

}

```

}

On Fri, Jun 29, 2012 at 7:34 PM, Rafał Kuć \<[r.kuc@solr.pl](mailto:r.kuc@solr.pl)\> wrote:

Hello!

This usually means that the client can't connect to the cluster. Could you post the code ?

_--_

Regards,

Rafał Kuć

Sematext ::

[http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

Hi Rafal,

Now I get "org.elasticsearch.client.transport.NoNodeAvailableException" ☹

I dont see any problems while indexing contents thru cURL...

Thanks,

Baahu

On Fri, Jun 29, 2012 at 7:14 PM, Rafał Kuć \<[r.kuc@solr.pl](mailto:r.kuc@solr.pl)\> wrote:

Hello!

Can you try connecting with the TransportClient. This code should do the work:

TransportClient client = new TransportClient(ImmutableSettings.settingsBuilder().put("[cluster.name](http://cluster.name)", "elasticsearch").build());

client.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));

_--_

Regards,

Rafał Kuć

Sematext ::

[http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

Hi Rafał,

I get the exception **org.elasticsearch.discovery.MasterNotDiscoveredException** : .

I set the clustername to "elasticsearch" (In elasticsearch.yml the [cluster.name](http://cluster.name) is set to elasticsearch.)

Thanks,

Baahu

On Fri, Jun 29, 2012 at 6:40 PM, Rafał Kuć \<[r.kuc@solr.pl](mailto:r.kuc@solr.pl)\> wrote:

Hello!

I think you are starting a new node, instead of connecting to your instance. Try the following:

Client client = NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();

Instead of your:

"

Node node = NodeBuilder.nodeBuilder().node().start();

Client client = node.client ();

"

Please notice that you need to provide a cluster name.

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

Hi,

Below is a sample program to index some content to the ES running in localhost on 9200.But I dont see this indexing the content, I dont see the testtweet folder being created in the data folder.I am trying this in windows.

public class Main {

```
public static void main(String[] args) {

    Node node = NodeBuilder.nodeBuilder().node().start();

    

    Client client = node.client ();

    

    try {

        IndexResponse response = client

                .prepareIndex("testtweet", "tweet1", "0")

                .setSource(

                        jsonBuilder()

                                .startObject()

                                .field("user", "kimchy")

                                .field("postDate", new Date())

                                .field("message",

                                        "trying out Elastic Search")

                                .endObject()).execute().actionGet();

        System.out.println("Done");

    } catch (ElasticSearchException e) {

        e.printStackTrace();

    } catch (IOException e) {

        e.printStackTrace();

    }

    node.close();

}

```

}

--

Twitter:[http://](http://twitter.com/Baahu)[twitter](http://twitter.com/Baahu)[.com/Baahu](http://twitter.com/Baahu)

--

Twitter:[http://](http://twitter.com/Baahu)[twitter](http://twitter.com/Baahu)[.com/Baahu](http://twitter.com/Baahu)

--

Twitter:[http://](http://twitter.com/Baahu)[twitter](http://twitter.com/Baahu)[.com/Baahu](http://twitter.com/Baahu)

---

<div class="post-metadata">

**Author:** ![Bahubali\_Jain](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@Bahubali\_Jain](https://discuss.elastic.co/u/Bahubali_Jain)\
**Post date:** [June 29, 2012, 2:44pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/9 "2012-06-29T14:44:30Z")

</div>

Hi,  
Yes it does listens on localhost(windows)...I am able to query and index  
thru curl.I am attaching the elasticsearch.yml file (almost everything is  
commented in it though).  
Even I have the 19.4 version.

Thanks,  
Baahu

On Fri, Jun 29, 2012 at 8:03 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:

> Hello!
> 
> Just tested your code with ES 0.19.4 - no problem with connecting to my  
> local instance with the code exactly copy pasted from your post.
> 
> Are you sure, your Elasticsearch instance listens on localhost ?
> 
> _--  
> Regards,  
> Rafał Kuć  
> Sematext :: \*  
> [http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch - Elasticsearch
> 
> - 
> 
> Hi Rafal,
> 
> Here you go..
> 
> import static org.elasticsearch.node.NodeBuilder._;  
> import static org.elasticsearch.common.xcontent.XContentFactory._;
> 
> import java.io.IOException;  
> import java.util.Date;
> 
> import org.elasticsearch.ElasticSearchException;  
> import org.elasticsearch.action.index.IndexResponse;  
> import org.elasticsearch.client.Client;  
> import org.elasticsearch.client.transport.TransportClient;  
> import org.elasticsearch.common.settings.ImmutableSettings;  
> import org.elasticsearch.common.settings.Settings;  
> import org.elasticsearch.common.transport.InetSocketTransportAddress;  
> import org.elasticsearch.node.Node;  
> import org.elasticsearch.node.NodeBuilder;  
> public class Main {  
> public static void main(String args) {
> 
> ```
> TransportClient client = new
> 
> ```
> 
> TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name",  
> "elasticsearch").build());  
> client.addTransportAddress(new  
> InetSocketTransportAddress("localhost", 9300));
> 
> ```
> try {
> IndexResponse response = client
> .prepareIndex("testtweet", "tweet1", "0")
> .setSource(
> jsonBuilder()
> .startObject()
> .field("user", "kimchy")
> .field("postDate", new Date())
> .field("message",
> "trying out Elastic Search")
> .endObject()).execute().actionGet();
> System.out.println("Done");
> } catch (ElasticSearchException e) {
> 
> e.printStackTrace();
> } catch (IOException e) {
> 
> e.printStackTrace();
> }
> 
> //node.close();
> 
> }
> 
> ```
> 
> }
> 
> On Fri, Jun 29, 2012 at 7:34 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> This usually means that the client can't connect to the cluster. Could you  
> post the code ?
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext ::  
> _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch - Elasticsearch
> 
> - 
> 
> Hi Rafal,  
> Now I get "org.elasticsearch.client.transport.NoNodeAvailableException" ☹
> 
> I dont see any problems while indexing contents thru cURL...
> 
> Thanks,  
> Baahu
> 
> On Fri, Jun 29, 2012 at 7:14 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> Can you try connecting with the TransportClient. This code should do the  
> work:
> 
> TransportClient client = new  
> TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name",  
> "elasticsearch").build());  
> client.addTransportAddress(new InetSocketTransportAddress("localhost",  
> 9300));
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext ::  
> _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch - Elasticsearch
> 
> - 
> 
> Hi Rafał,  
> I get the exception \*  
> org.elasticsearch.discovery.MasterNotDiscoveredException\*: .  
> I set the clustername to "elasticsearch" (In elasticsearch.yml the  
> cluster.name is set to elasticsearch.)
> 
> Thanks,  
> Baahu
> 
> On Fri, Jun 29, 2012 at 6:40 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> I think you are starting a new node, instead of connecting to your  
> instance. Try the following:
> 
> Client client =  
> NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();
> 
> Instead of your:
> 
> "  
> Node node = NodeBuilder.nodeBuilder().node().start();
> 
> Client client = node.client ();  
> "
> 
> Please notice that you need to provide a cluster name.
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch -  
> Elasticsearch
> 
> - 
> 
> Hi,  
> Below is a sample program to index some content to the ES running in  
> localhost on 9200.But I dont see this indexing the content, I dont see the  
> testtweet folder being created in the data folder.I am trying this in  
> windows.
> 
> public class Main {  
> public static void main(String args) {  
> Node node = NodeBuilder.nodeBuilder().node().start();
> 
> ```
> Client client = node.client ();
> 
> try {
> IndexResponse response = client
> .prepareIndex("testtweet", "tweet1", "0")
> .setSource(
> jsonBuilder()
> .startObject()
> .field("user", "kimchy")
> .field("postDate", new Date())
> .field("message",
> "trying out Elastic Search")
> .endObject()).execute().actionGet();
> System.out.println("Done");
> } catch (ElasticSearchException e) {
> 
> e.printStackTrace();
> } catch (IOException e) {
> 
> e.printStackTrace();
> }
> 
> node.close();
> 
> }
> 
> ```
> 
> }
> 
> --  
> Twitter:http:// [http://twitter.com/Baahu](http://twitter.com/Baahu)twitter[http://twitter.com/Baahu](http://twitter.com/Baahu)  
> .com/Baahu [http://twitter.com/Baahu](http://twitter.com/Baahu)
> 
> --  
> Twitter:http:// [http://twitter.com/Baahu](http://twitter.com/Baahu)twitter[http://twitter.com/Baahu](http://twitter.com/Baahu)  
> .com/Baahu [http://twitter.com/Baahu](http://twitter.com/Baahu)
> 
> --  
> Twitter:http:// [http://twitter.com/Baahu](http://twitter.com/Baahu)twitter[http://twitter.com/Baahu](http://twitter.com/Baahu)  
> .com/Baahu [http://twitter.com/Baahu](http://twitter.com/Baahu)

--  
Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 29, 2012, 3:37pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/10 "2012-06-29T15:37:07Z")

</div>

Check if you have any firewall rules on port 9300.

David

Le 29 juin 2012 à 16:44, Baahu [bahubali@gmail.com](mailto:bahubali@gmail.com) a écrit :

> Hi,  
> Yes it does listens on localhost(windows)...I am able to query and index thru curl.I am attaching the elasticsearch.yml file (almost everything is commented in it though).  
> Even I have the 19.4 version.
> 
> Thanks,  
> Baahu
> 
> On Fri, Jun 29, 2012 at 8:03 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> Just tested your code with ES 0.19.4 - no problem with connecting to my local instance with the code exactly copy pasted from your post.
> 
> Are you sure, your Elasticsearch instance listens on localhost ?
> 
> --  
> Regards,  
> Rafał Kuć  
> Sematext ::  
> [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> 
> Hi Rafal,
> 
> Here you go..
> 
> import static org.elasticsearch.node.NodeBuilder._;  
> import static org.elasticsearch.common.xcontent.XContentFactory._;
> 
> import java.io.IOException;  
> import java.util.Date;
> 
> import org.elasticsearch.ElasticSearchException;  
> import org.elasticsearch.action.index.IndexResponse;  
> import org.elasticsearch.client.Client;  
> import org.elasticsearch.client.transport.TransportClient;  
> import org.elasticsearch.common.settings.ImmutableSettings;  
> import org.elasticsearch.common.settings.Settings;  
> import org.elasticsearch.common.transport.InetSocketTransportAddress;  
> import org.elasticsearch.node.Node;  
> import org.elasticsearch.node.NodeBuilder;  
> public class Main {  
> public static void main(String args) {
> 
> ```
> TransportClient client = new TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch").build());
> client.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
>             
> try {
> IndexResponse response = client
> .prepareIndex("testtweet", "tweet1", "0")
> .setSource(
> jsonBuilder()
> .startObject()
> .field("user", "kimchy")
> .field("postDate", new Date())
> .field("message",
> "trying out Elastic Search")
> .endObject()).execute().actionGet();
> System.out.println("Done");
> } catch (ElasticSearchException e) {
> 
> e.printStackTrace();
> } catch (IOException e) {
> 
> e.printStackTrace();
> }
> 
> //node.close();
> 
> }
> 
> ```
> 
> }
> 
> On Fri, Jun 29, 2012 at 7:34 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> This usually means that the client can't connect to the cluster. Could you post the code ?
> 
> --  
> Regards,  
> Rafał Kuć  
> Sematext ::  
> [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> 
> Hi Rafal,  
> Now I get "org.elasticsearch.client.transport.NoNodeAvailableException" ☹
> 
> I dont see any problems while indexing contents thru cURL...
> 
> Thanks,  
> Baahu
> 
> On Fri, Jun 29, 2012 at 7:14 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> Can you try connecting with the TransportClient. This code should do the work:
> 
> TransportClient client = new TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch").build());  
> client.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
> 
> --  
> Regards,  
> Rafał Kuć  
> Sematext ::  
> [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> 
> Hi Rafał,  
> I get the exception org.elasticsearch.discovery.MasterNotDiscoveredException: .  
> I set the clustername to "elasticsearch" (In elasticsearch.yml the cluster.name is set to elasticsearch.)
> 
> Thanks,  
> Baahu
> 
> On Fri, Jun 29, 2012 at 6:40 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> I think you are starting a new node, instead of connecting to your instance. Try the following:
> 
> Client client = NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();
> 
> Instead of your:
> 
> "  
> Node node = NodeBuilder.nodeBuilder().node().start();
> 
> Client client = node.client ();  
> "
> 
> Please notice that you need to provide a cluster name.
> 
> --  
> Regards,  
> Rafał Kuć  
> Sematext :: [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> 
> Hi,  
> Below is a sample program to index some content to the ES running in localhost on 9200.But I dont see this indexing the content, I dont see the testtweet folder being created in the data folder.I am trying this in windows.
> 
> public class Main {  
> public static void main(String args) {  
> Node node = NodeBuilder.nodeBuilder().node().start();
> 
> ```
> Client client = node.client ();
>     
> try {
> IndexResponse response = client
> .prepareIndex("testtweet", "tweet1", "0")
> .setSource(
> jsonBuilder()
> .startObject()
> .field("user", "kimchy")
> .field("postDate", new Date())
> .field("message",
> "trying out Elastic Search")
> .endObject()).execute().actionGet();
> System.out.println("Done");
> } catch (ElasticSearchException e) {
> 
> e.printStackTrace();
> } catch (IOException e) {
> 
> e.printStackTrace();
> }
> 
> node.close();
> 
> }
> 
> ```
> 
> }
> 
> --  
> Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> 
> --  
> Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> 
> --  
> Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> 
> --  
> Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> 
> \<elasticsearch.yml\>

---

<div class="post-metadata">

**Author:** ![Bahubali\_Jain](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@Bahubali\_Jain](https://discuss.elastic.co/u/Bahubali_Jain)\
**Post date:** [June 29, 2012, 5:23pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/11 "2012-06-29T17:23:41Z")

</div>

Yes, firewall seemed to be the problem.Its working using the  
TransportClient.  
For whatever reasons using the nodebuilder still gives the problem.

Thanks Rafal and David for the help.  
Is there any documentation which newbies like me can refer to ? The  
documentation on elasticsearch,.org isnt that straighforward for newbies.

On Fri, Jun 29, 2012 at 9:07 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Check if you have any firewall rules on port 9300.
> 
> David
> 
> Le 29 juin 2012 à 16:44, Baahu [bahubali@gmail.com](mailto:bahubali@gmail.com) a écrit :
> 
> Hi,  
> Yes it does listens on localhost(windows)...I am able to query and index  
> thru curl.I am attaching the elasticsearch.yml file (almost everything is  
> commented in it though).  
> Even I have the 19.4 version.
> 
> Thanks,  
> Baahu
> 
> On Fri, Jun 29, 2012 at 8:03 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:
> 
> > Hello!
> > 
> > Just tested your code with ES 0.19.4 - no problem with connecting to my  
> > local instance with the code exactly copy pasted from your post.
> > 
> > Are you sure, your Elasticsearch instance listens on localhost ?
> > 
> > _--  
> > Regards,  
> > Rafał Kuć  
> > Sematext :: \*  
> > [http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch - Elasticsearch
> > 
> > - 
> > 
> > Hi Rafal,
> > 
> > Here you go..
> > 
> > import static org.elasticsearch.node.NodeBuilder._;  
> > import static org.elasticsearch.common.xcontent.XContentFactory._;
> > 
> > import java.io.IOException;  
> > import java.util.Date;
> > 
> > import org.elasticsearch.ElasticSearchException;  
> > import org.elasticsearch.action.index.IndexResponse;  
> > import org.elasticsearch.client.Client;  
> > import org.elasticsearch.client.transport.TransportClient;  
> > import org.elasticsearch.common.settings.ImmutableSettings;  
> > import org.elasticsearch.common.settings.Settings;  
> > import org.elasticsearch.common.transport.InetSocketTransportAddress;  
> > import org.elasticsearch.node.Node;  
> > import org.elasticsearch.node.NodeBuilder;  
> > public class Main {  
> > public static void main(String args) {
> > 
> > ```
> > TransportClient client = new
> > 
> > ```
> > 
> > TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name",  
> > "elasticsearch").build());  
> > client.addTransportAddress(new  
> > InetSocketTransportAddress("localhost", 9300));
> > 
> > ```
> > try {
> > IndexResponse response = client
> > .prepareIndex("testtweet", "tweet1", "0")
> > .setSource(
> > jsonBuilder()
> > .startObject()
> > .field("user", "kimchy")
> > .field("postDate", new Date())
> > .field("message",
> > "trying out Elastic Search")
> > .endObject()).execute().actionGet();
> > System.out.println("Done");
> > } catch (ElasticSearchException e) {
> > 
> > e.printStackTrace();
> > } catch (IOException e) {
> > 
> > e.printStackTrace();
> > }
> > 
> > //node.close();
> > 
> > }
> > 
> > ```
> > 
> > }
> > 
> > On Fri, Jun 29, 2012 at 7:34 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > Hello!
> > 
> > This usually means that the client can't connect to the cluster. Could  
> > you post the code ?
> > 
> > \*--  
> > Regards,  
> > Rafał Kuć  
> > Sematext ::  
> > _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch - Elasticsearch
> > 
> > - 
> > 
> > Hi Rafal,  
> > Now I get "org.elasticsearch.client.transport.NoNodeAvailableException"  
> > ☹
> > 
> > I dont see any problems while indexing contents thru cURL...
> > 
> > Thanks,  
> > Baahu
> > 
> > On Fri, Jun 29, 2012 at 7:14 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > Hello!
> > 
> > Can you try connecting with the TransportClient. This code should do the  
> > work:
> > 
> > TransportClient client = new  
> > TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name",  
> > "elasticsearch").build());  
> > client.addTransportAddress(new InetSocketTransportAddress("localhost",  
> > 9300));
> > 
> > \*--  
> > Regards,  
> > Rafał Kuć  
> > Sematext ::  
> > _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch - Elasticsearch
> > 
> > - 
> > 
> > Hi Rafał,  
> > I get the exception \*  
> > org.elasticsearch.discovery.MasterNotDiscoveredException\*: .  
> > I set the clustername to "elasticsearch" (In elasticsearch.yml the  
> > cluster.name is set to elasticsearch.)
> > 
> > Thanks,  
> > Baahu
> > 
> > On Fri, Jun 29, 2012 at 6:40 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > Hello!
> > 
> > I think you are starting a new node, instead of connecting to your  
> > instance. Try the following:
> > 
> > Client client =  
> > NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();
> > 
> > Instead of your:
> > 
> > "  
> > Node node = NodeBuilder.nodeBuilder().node().start();
> > 
> > Client client = node.client ();  
> > "
> > 
> > Please notice that you need to provide a cluster name.
> > 
> > \*--  
> > Regards,  
> > Rafał Kuć  
> > Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch -  
> > Elasticsearch
> > 
> > - 
> > 
> > Hi,  
> > Below is a sample program to index some content to the ES running in  
> > localhost on 9200.But I dont see this indexing the content, I dont see the  
> > testtweet folder being created in the data folder.I am trying this in  
> > windows.
> > 
> > public class Main {  
> > public static void main(String args) {  
> > Node node = NodeBuilder.nodeBuilder().node().start();
> > 
> > ```
> > Client client = node.client ();
> > 
> > try {
> > IndexResponse response = client
> > .prepareIndex("testtweet", "tweet1", "0")
> > .setSource(
> > jsonBuilder()
> > .startObject()
> > .field("user", "kimchy")
> > .field("postDate", new Date())
> > .field("message",
> > "trying out Elastic Search")
> > .endObject()).execute().actionGet();
> > System.out.println("Done");
> > } catch (ElasticSearchException e) {
> > 
> > e.printStackTrace();
> > } catch (IOException e) {
> > 
> > e.printStackTrace();
> > }
> > 
> > node.close();
> > 
> > }
> > 
> > ```
> > 
> > }
> > 
> > --  
> > Twitter:http:// [http://twitter.com/Baahu](http://twitter.com/Baahu)twitter[http://twitter.com/Baahu](http://twitter.com/Baahu)  
> > .com/Baahu [http://twitter.com/Baahu](http://twitter.com/Baahu)
> > 
> > --  
> > Twitter:http:// [http://twitter.com/Baahu](http://twitter.com/Baahu)twitter[http://twitter.com/Baahu](http://twitter.com/Baahu)  
> > .com/Baahu [http://twitter.com/Baahu](http://twitter.com/Baahu)
> > 
> > --  
> > Twitter:http:// [http://twitter.com/Baahu](http://twitter.com/Baahu)twitter[http://twitter.com/Baahu](http://twitter.com/Baahu)  
> > .com/Baahu [http://twitter.com/Baahu](http://twitter.com/Baahu)
> 
> --  
> Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> 
> \<elasticsearch.yml\>

--  
Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 29, 2012, 5:37pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/12 "2012-06-29T17:37:27Z")

</div>

What do you mean by "Its working using the TransportClient ?  
So if it works, what is the problem ?

David

Le 29 juin 2012 à 19:23, Baahu [bahubali@gmail.com](mailto:bahubali@gmail.com) a écrit :

> Yes, firewall seemed to be the problem.Its working using the TransportClient.  
> For whatever reasons using the nodebuilder still gives the problem.
> 
> Thanks Rafal and David for the help.  
> Is there any documentation which newbies like me can refer to ? The documentation on elasticsearch,.org isnt that straighforward for newbies.
> 
> On Fri, Jun 29, 2012 at 9:07 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> Check if you have any firewall rules on port 9300.
> 
> David
> 
> Le 29 juin 2012 à 16:44, Baahu [bahubali@gmail.com](mailto:bahubali@gmail.com) a écrit :
> 
> > Hi,  
> > Yes it does listens on localhost(windows)...I am able to query and index thru curl.I am attaching the elasticsearch.yml file (almost everything is commented in it though).  
> > Even I have the 19.4 version.
> > 
> > Thanks,  
> > Baahu
> > 
> > On Fri, Jun 29, 2012 at 8:03 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > Hello!
> > 
> > Just tested your code with ES 0.19.4 - no problem with connecting to my local instance with the code exactly copy pasted from your post.
> > 
> > Are you sure, your Elasticsearch instance listens on localhost ?
> > 
> > --  
> > Regards,  
> > Rafał Kuć  
> > Sematext ::  
> > [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> > 
> > Hi Rafal,
> > 
> > Here you go..
> > 
> > import static org.elasticsearch.node.NodeBuilder._;  
> > import static org.elasticsearch.common.xcontent.XContentFactory._;
> > 
> > import java.io.IOException;  
> > import java.util.Date;
> > 
> > import org.elasticsearch.ElasticSearchException;  
> > import org.elasticsearch.action.index.IndexResponse;  
> > import org.elasticsearch.client.Client;  
> > import org.elasticsearch.client.transport.TransportClient;  
> > import org.elasticsearch.common.settings.ImmutableSettings;  
> > import org.elasticsearch.common.settings.Settings;  
> > import org.elasticsearch.common.transport.InetSocketTransportAddress;  
> > import org.elasticsearch.node.Node;  
> > import org.elasticsearch.node.NodeBuilder;  
> > public class Main {  
> > public static void main(String args) {
> > 
> > ```
> > TransportClient client = new TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch").build());
> > client.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
> >             
> > try {
> > IndexResponse response = client
> > .prepareIndex("testtweet", "tweet1", "0")
> > .setSource(
> > jsonBuilder()
> > .startObject()
> > .field("user", "kimchy")
> > .field("postDate", new Date())
> > .field("message",
> > "trying out Elastic Search")
> > .endObject()).execute().actionGet();
> > System.out.println("Done");
> > } catch (ElasticSearchException e) {
> > 
> > e.printStackTrace();
> > } catch (IOException e) {
> > 
> > e.printStackTrace();
> > }
> > 
> > //node.close();
> > 
> > }
> > 
> > ```
> > 
> > }
> > 
> > On Fri, Jun 29, 2012 at 7:34 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > Hello!
> > 
> > This usually means that the client can't connect to the cluster. Could you post the code ?
> > 
> > --  
> > Regards,  
> > Rafał Kuć  
> > Sematext ::  
> > [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> > 
> > Hi Rafal,  
> > Now I get "org.elasticsearch.client.transport.NoNodeAvailableException" ☹
> > 
> > I dont see any problems while indexing contents thru cURL...
> > 
> > Thanks,  
> > Baahu
> > 
> > On Fri, Jun 29, 2012 at 7:14 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > Hello!
> > 
> > Can you try connecting with the TransportClient. This code should do the work:
> > 
> > TransportClient client = new TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch").build());  
> > client.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
> > 
> > --  
> > Regards,  
> > Rafał Kuć  
> > Sematext ::  
> > [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> > 
> > Hi Rafał,  
> > I get the exception org.elasticsearch.discovery.MasterNotDiscoveredException: .  
> > I set the clustername to "elasticsearch" (In elasticsearch.yml the cluster.name is set to elasticsearch.)
> > 
> > Thanks,  
> > Baahu
> > 
> > On Fri, Jun 29, 2012 at 6:40 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > Hello!
> > 
> > I think you are starting a new node, instead of connecting to your instance. Try the following:
> > 
> > Client client = NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();
> > 
> > Instead of your:
> > 
> > "  
> > Node node = NodeBuilder.nodeBuilder().node().start();
> > 
> > Client client = node.client ();  
> > "
> > 
> > Please notice that you need to provide a cluster name.
> > 
> > --  
> > Regards,  
> > Rafał Kuć  
> > Sematext :: [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> > 
> > Hi,  
> > Below is a sample program to index some content to the ES running in localhost on 9200.But I dont see this indexing the content, I dont see the testtweet folder being created in the data folder.I am trying this in windows.
> > 
> > public class Main {  
> > public static void main(String args) {  
> > Node node = NodeBuilder.nodeBuilder().node().start();
> > 
> > ```
> > Client client = node.client ();
> >     
> > try {
> > IndexResponse response = client
> > .prepareIndex("testtweet", "tweet1", "0")
> > .setSource(
> > jsonBuilder()
> > .startObject()
> > .field("user", "kimchy")
> > .field("postDate", new Date())
> > .field("message",
> > "trying out Elastic Search")
> > .endObject()).execute().actionGet();
> > System.out.println("Done");
> > } catch (ElasticSearchException e) {
> > 
> > e.printStackTrace();
> > } catch (IOException e) {
> > 
> > e.printStackTrace();
> > }
> > 
> > node.close();
> > 
> > }
> > 
> > ```
> > 
> > }
> > 
> > --  
> > Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> > 
> > --  
> > Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> > 
> > --  
> > Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> > 
> > --  
> > Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> > 
> > \<elasticsearch.yml\>
> 
> --  
> Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)

---

<div class="post-metadata">

**Author:** ![Bahubali\_Jain](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@Bahubali\_Jain](https://discuss.elastic.co/u/Bahubali_Jain)\
**Post date:** [June 29, 2012, 5:45pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/13 "2012-06-29T17:45:02Z")

</div>

No problem that i had actually mentioned in the previous mail:) ...  
On Jun 29, 2012 11:07 PM, "David Pilato" [david@pilato.fr](mailto:david@pilato.fr) wrote:

> What do you mean by "Its working using the TransportClient ?  
> So if it works, what is the problem ?
> 
> David
> 
> Le 29 juin 2012 à 19:23, Baahu [bahubali@gmail.com](mailto:bahubali@gmail.com) a écrit :
> 
> Yes, firewall seemed to be the problem.Its working using the  
> TransportClient.  
> For whatever reasons using the nodebuilder still gives the problem.
> 
> Thanks Rafal and David for the help.  
> Is there any documentation which newbies like me can refer to ? The  
> documentation on elasticsearch,.org isnt that straighforward for newbies.
> 
> On Fri, Jun 29, 2012 at 9:07 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> 
> > Check if you have any firewall rules on port 9300.
> > 
> > David
> > 
> > Le 29 juin 2012 à 16:44, Baahu [bahubali@gmail.com](mailto:bahubali@gmail.com) a écrit :
> > 
> > Hi,  
> > Yes it does listens on localhost(windows)...I am able to query and index  
> > thru curl.I am attaching the elasticsearch.yml file (almost everything is  
> > commented in it though).  
> > Even I have the 19.4 version.
> > 
> > Thanks,  
> > Baahu
> > 
> > On Fri, Jun 29, 2012 at 8:03 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:
> > 
> > > Hello!
> > > 
> > > Just tested your code with ES 0.19.4 - no problem with connecting to my  
> > > local instance with the code exactly copy pasted from your post.
> > > 
> > > Are you sure, your Elasticsearch instance listens on localhost ?
> > > 
> > > _--  
> > > Regards,  
> > > Rafał Kuć  
> > > Sematext :: \*  
> > > [http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch - Elasticsearch
> > > 
> > > - 
> > > 
> > > Hi Rafal,
> > > 
> > > Here you go..
> > > 
> > > import static org.elasticsearch.node.NodeBuilder._;  
> > > import static org.elasticsearch.common.xcontent.XContentFactory._;
> > > 
> > > import java.io.IOException;  
> > > import java.util.Date;
> > > 
> > > import org.elasticsearch.ElasticSearchException;  
> > > import org.elasticsearch.action.index.IndexResponse;  
> > > import org.elasticsearch.client.Client;  
> > > import org.elasticsearch.client.transport.TransportClient;  
> > > import org.elasticsearch.common.settings.ImmutableSettings;  
> > > import org.elasticsearch.common.settings.Settings;  
> > > import org.elasticsearch.common.transport.InetSocketTransportAddress;  
> > > import org.elasticsearch.node.Node;  
> > > import org.elasticsearch.node.NodeBuilder;  
> > > public class Main {  
> > > public static void main(String args) {
> > > 
> > > ```
> > > TransportClient client = new
> > > 
> > > ```
> > > 
> > > TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name",  
> > > "elasticsearch").build());  
> > > client.addTransportAddress(new  
> > > InetSocketTransportAddress("localhost", 9300));
> > > 
> > > ```
> > > try {
> > > IndexResponse response = client
> > > .prepareIndex("testtweet", "tweet1", "0")
> > > .setSource(
> > > jsonBuilder()
> > > .startObject()
> > > .field("user", "kimchy")
> > > .field("postDate", new Date())
> > > .field("message",
> > > "trying out Elastic Search")
> > > .endObject()).execute().actionGet();
> > > System.out.println("Done");
> > > } catch (ElasticSearchException e) {
> > > 
> > > e.printStackTrace();
> > > } catch (IOException e) {
> > > 
> > > e.printStackTrace();
> > > }
> > > 
> > > //node.close();
> > > 
> > > }
> > > 
> > > ```
> > > 
> > > }
> > > 
> > > On Fri, Jun 29, 2012 at 7:34 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > > Hello!
> > > 
> > > This usually means that the client can't connect to the cluster. Could  
> > > you post the code ?
> > > 
> > > \*--  
> > > Regards,  
> > > Rafał Kuć  
> > > Sematext ::  
> > > _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch - Elasticsearch
> > > 
> > > - 
> > > 
> > > Hi Rafal,  
> > > Now I get "org.elasticsearch.client.transport.NoNodeAvailableException"  
> > > ☹
> > > 
> > > I dont see any problems while indexing contents thru cURL...
> > > 
> > > Thanks,  
> > > Baahu
> > > 
> > > On Fri, Jun 29, 2012 at 7:14 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > > Hello!
> > > 
> > > Can you try connecting with the TransportClient. This code should do the  
> > > work:
> > > 
> > > TransportClient client = new  
> > > TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name",  
> > > "elasticsearch").build());  
> > > client.addTransportAddress(new InetSocketTransportAddress("localhost",  
> > > 9300));
> > > 
> > > \*--  
> > > Regards,  
> > > Rafał Kuć  
> > > Sematext ::  
> > > _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch - Elasticsearch
> > > 
> > > - 
> > > 
> > > Hi Rafał,  
> > > I get the exception \*  
> > > org.elasticsearch.discovery.MasterNotDiscoveredException\*: .  
> > > I set the clustername to "elasticsearch" (In elasticsearch.yml the  
> > > cluster.name is set to elasticsearch.)
> > > 
> > > Thanks,  
> > > Baahu
> > > 
> > > On Fri, Jun 29, 2012 at 6:40 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > > Hello!
> > > 
> > > I think you are starting a new node, instead of connecting to your  
> > > instance. Try the following:
> > > 
> > > Client client =  
> > > NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();
> > > 
> > > Instead of your:
> > > 
> > > "  
> > > Node node = NodeBuilder.nodeBuilder().node().start();
> > > 
> > > Client client = node.client ();  
> > > "
> > > 
> > > Please notice that you need to provide a cluster name.
> > > 
> > > \*--  
> > > Regards,  
> > > Rafał Kuć  
> > > Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch -  
> > > Elasticsearch
> > > 
> > > - 
> > > 
> > > Hi,  
> > > Below is a sample program to index some content to the ES running in  
> > > localhost on 9200.But I dont see this indexing the content, I dont see the  
> > > testtweet folder being created in the data folder.I am trying this in  
> > > windows.
> > > 
> > > public class Main {  
> > > public static void main(String args) {  
> > > Node node = NodeBuilder.nodeBuilder().node().start();
> > > 
> > > ```
> > > Client client = node.client ();
> > > 
> > > try {
> > > IndexResponse response = client
> > > .prepareIndex("testtweet", "tweet1", "0")
> > > .setSource(
> > > jsonBuilder()
> > > .startObject()
> > > .field("user", "kimchy")
> > > .field("postDate", new Date())
> > > .field("message",
> > > "trying out Elastic Search")
> > > .endObject()).execute().actionGet();
> > > System.out.println("Done");
> > > } catch (ElasticSearchException e) {
> > > 
> > > e.printStackTrace();
> > > } catch (IOException e) {
> > > 
> > > e.printStackTrace();
> > > }
> > > 
> > > node.close();
> > > 
> > > }
> > > 
> > > ```
> > > 
> > > }
> > > 
> > > --  
> > > Twitter:http:// [http://twitter.com/Baahu](http://twitter.com/Baahu)twitter[http://twitter.com/Baahu](http://twitter.com/Baahu)  
> > > .com/Baahu [http://twitter.com/Baahu](http://twitter.com/Baahu)
> > > 
> > > --  
> > > Twitter:http:// [http://twitter.com/Baahu](http://twitter.com/Baahu)twitter[http://twitter.com/Baahu](http://twitter.com/Baahu)  
> > > .com/Baahu [http://twitter.com/Baahu](http://twitter.com/Baahu)
> > > 
> > > --  
> > > Twitter:http:// [http://twitter.com/Baahu](http://twitter.com/Baahu)twitter[http://twitter.com/Baahu](http://twitter.com/Baahu)  
> > > .com/Baahu [http://twitter.com/Baahu](http://twitter.com/Baahu)
> > 
> > --  
> > Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> > 
> > \<elasticsearch.yml\>
> 
> --  
> Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 29, 2012, 6:06pm UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/14 "2012-06-29T18:06:27Z")

</div>

Sorry, I don't understand.

Is the code Rafal gaves you works or not ?

You said at first that it's not working (using the TransportClient) and said in your last mail that TransportClient works.

So ?

--  
David

Le 29 juin 2012 à 19:45, Baahu [bahubali@gmail.com](mailto:bahubali@gmail.com) a écrit :

> No problem that i had actually mentioned in the previous mail:) ...
> 
> On Jun 29, 2012 11:07 PM, "David Pilato" [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> What do you mean by "Its working using the TransportClient ?  
> So if it works, what is the problem ?
> 
> David
> 
> Le 29 juin 2012 à 19:23, Baahu [bahubali@gmail.com](mailto:bahubali@gmail.com) a écrit :
> 
> > Yes, firewall seemed to be the problem.Its working using the TransportClient.  
> > For whatever reasons using the nodebuilder still gives the problem.
> > 
> > Thanks Rafal and David for the help.  
> > Is there any documentation which newbies like me can refer to ? The documentation on elasticsearch,.org isnt that straighforward for newbies.
> > 
> > On Fri, Jun 29, 2012 at 9:07 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> > Check if you have any firewall rules on port 9300.
> > 
> > David
> > 
> > Le 29 juin 2012 à 16:44, Baahu [bahubali@gmail.com](mailto:bahubali@gmail.com) a écrit :
> > 
> > > Hi,  
> > > Yes it does listens on localhost(windows)...I am able to query and index thru curl.I am attaching the elasticsearch.yml file (almost everything is commented in it though).  
> > > Even I have the 19.4 version.
> > > 
> > > Thanks,  
> > > Baahu
> > > 
> > > On Fri, Jun 29, 2012 at 8:03 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > > Hello!
> > > 
> > > Just tested your code with ES 0.19.4 - no problem with connecting to my local instance with the code exactly copy pasted from your post.
> > > 
> > > Are you sure, your Elasticsearch instance listens on localhost ?
> > > 
> > > --  
> > > Regards,  
> > > Rafał Kuć  
> > > Sematext ::  
> > > [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> > > 
> > > Hi Rafal,
> > > 
> > > Here you go..
> > > 
> > > import static org.elasticsearch.node.NodeBuilder._;  
> > > import static org.elasticsearch.common.xcontent.XContentFactory._;
> > > 
> > > import java.io.IOException;  
> > > import java.util.Date;
> > > 
> > > import org.elasticsearch.ElasticSearchException;  
> > > import org.elasticsearch.action.index.IndexResponse;  
> > > import org.elasticsearch.client.Client;  
> > > import org.elasticsearch.client.transport.TransportClient;  
> > > import org.elasticsearch.common.settings.ImmutableSettings;  
> > > import org.elasticsearch.common.settings.Settings;  
> > > import org.elasticsearch.common.transport.InetSocketTransportAddress;  
> > > import org.elasticsearch.node.Node;  
> > > import org.elasticsearch.node.NodeBuilder;  
> > > public class Main {  
> > > public static void main(String args) {
> > > 
> > > ```
> > > TransportClient client = new TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch").build());
> > > client.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
> > >             
> > > try {
> > > IndexResponse response = client
> > > .prepareIndex("testtweet", "tweet1", "0")
> > > .setSource(
> > > jsonBuilder()
> > > .startObject()
> > > .field("user", "kimchy")
> > > .field("postDate", new Date())
> > > .field("message",
> > > "trying out Elastic Search")
> > > .endObject()).execute().actionGet();
> > > System.out.println("Done");
> > > } catch (ElasticSearchException e) {
> > > 
> > > e.printStackTrace();
> > > } catch (IOException e) {
> > > 
> > > e.printStackTrace();
> > > }
> > > 
> > > //node.close();
> > > 
> > > }
> > > 
> > > ```
> > > 
> > > }
> > > 
> > > On Fri, Jun 29, 2012 at 7:34 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > > Hello!
> > > 
> > > This usually means that the client can't connect to the cluster. Could you post the code ?
> > > 
> > > --  
> > > Regards,  
> > > Rafał Kuć  
> > > Sematext ::  
> > > [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> > > 
> > > Hi Rafal,  
> > > Now I get "org.elasticsearch.client.transport.NoNodeAvailableException" ☹
> > > 
> > > I dont see any problems while indexing contents thru cURL...
> > > 
> > > Thanks,  
> > > Baahu
> > > 
> > > On Fri, Jun 29, 2012 at 7:14 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > > Hello!
> > > 
> > > Can you try connecting with the TransportClient. This code should do the work:
> > > 
> > > TransportClient client = new TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch").build());  
> > > client.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
> > > 
> > > --  
> > > Regards,  
> > > Rafał Kuć  
> > > Sematext ::  
> > > [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> > > 
> > > Hi Rafał,  
> > > I get the exception org.elasticsearch.discovery.MasterNotDiscoveredException: .  
> > > I set the clustername to "elasticsearch" (In elasticsearch.yml the cluster.name is set to elasticsearch.)
> > > 
> > > Thanks,  
> > > Baahu
> > > 
> > > On Fri, Jun 29, 2012 at 6:40 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> > > Hello!
> > > 
> > > I think you are starting a new node, instead of connecting to your instance. Try the following:
> > > 
> > > Client client = NodeBuilder.nodeBuilder().client(true).clusterName(clusterName).node().client();
> > > 
> > > Instead of your:
> > > 
> > > "  
> > > Node node = NodeBuilder.nodeBuilder().node().start();
> > > 
> > > Client client = node.client ();  
> > > "
> > > 
> > > Please notice that you need to provide a cluster name.
> > > 
> > > --  
> > > Regards,  
> > > Rafał Kuć  
> > > Sematext :: [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> > > 
> > > Hi,  
> > > Below is a sample program to index some content to the ES running in localhost on 9200.But I dont see this indexing the content, I dont see the testtweet folder being created in the data folder.I am trying this in windows.
> > > 
> > > public class Main {  
> > > public static void main(String args) {  
> > > Node node = NodeBuilder.nodeBuilder().node().start();
> > > 
> > > ```
> > > Client client = node.client ();
> > >     
> > > try {
> > > IndexResponse response = client
> > > .prepareIndex("testtweet", "tweet1", "0")
> > > .setSource(
> > > jsonBuilder()
> > > .startObject()
> > > .field("user", "kimchy")
> > > .field("postDate", new Date())
> > > .field("message",
> > > "trying out Elastic Search")
> > > .endObject()).execute().actionGet();
> > > System.out.println("Done");
> > > } catch (ElasticSearchException e) {
> > > 
> > > e.printStackTrace();
> > > } catch (IOException e) {
> > > 
> > > e.printStackTrace();
> > > }
> > > 
> > > node.close();
> > > 
> > > }
> > > 
> > > ```
> > > 
> > > }
> > > 
> > > --  
> > > Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> > > 
> > > --  
> > > Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> > > 
> > > --  
> > > Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> > > 
> > > --  
> > > Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)
> > > 
> > > \<elasticsearch.yml\>
> > 
> > --  
> > Twitter:[http://twitter.com/Baahu](http://twitter.com/Baahu)

---

<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:22am UTC](https://discuss.elastic.co/t/help-with-simple-program/8260/15 "2017-07-06T03:22:01Z")

</div>


