Help with Simple Program


(Bahubali Jain) #1

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();

}

}


(Rafał Kuć) #2

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/ :: 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();




}

}


(Bahubali Jain) #3

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 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/ :: 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


(Rafał Kuć) #4

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/ :: 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> 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/ :: 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


(Bahubali Jain) #5

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

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 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/
:: 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 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/ :: 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/Baahutwitterhttp://twitter.com/Baahu
.com/Baahu http://twitter.com/Baahu

--
Twitter:http://twitter.com/Baahu


(Rafał Kuć) #6

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/ :: Solr - Lucene - Nutch - ElasticSearch

Hi Rafal,

Now I get "org.elasticsearch.client.transport.NoNodeAvailableException" :frowning:

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> 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/ :: 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> 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/ :: 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

--

Twitter:http://twitter.com/Baahu


(Bahubali Jain) #7

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 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/
:: Solr - Lucene - Nutch - ElasticSearch

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

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 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/ :: 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 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/ :: 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/Baahutwitterhttp://twitter.com/Baahu
.com/Baahu http://twitter.com/Baahu

--
Twitter:http:// http://twitter.com/Baahutwitterhttp://twitter.com/Baahu
.com/Baahu http://twitter.com/Baahu

--
Twitter:http://twitter.com/Baahu


(Rafał Kuć) #8

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/ :: 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> 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/ :: Solr - Lucene - Nutch - ElasticSearch

Hi Rafal,

Now I get "org.elasticsearch.client.transport.NoNodeAvailableException" :frowning:

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> 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/ :: 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> 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/ :: 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

--

Twitter:http://twitter.com/Baahu

--

Twitter:http://twitter.com/Baahu


(Bahubali Jain) #9

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 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/
:: 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 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/ :: Solr - Lucene - Nutch - ElasticSearch

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

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 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/ :: 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 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/ :: 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/Baahutwitterhttp://twitter.com/Baahu
.com/Baahu http://twitter.com/Baahu

--
Twitter:http:// http://twitter.com/Baahutwitterhttp://twitter.com/Baahu
.com/Baahu http://twitter.com/Baahu

--
Twitter:http:// http://twitter.com/Baahutwitterhttp://twitter.com/Baahu
.com/Baahu http://twitter.com/Baahu

--
Twitter:http://twitter.com/Baahu


(David Pilato) #10

Check if you have any firewall rules on port 9300.

David

Le 29 juin 2012 à 16:44, Baahu 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 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/ :: 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 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/ :: Solr - Lucene - Nutch - ElasticSearch

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

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 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/ :: 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 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/ :: 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

--
Twitter:http://twitter.com/Baahu

--
Twitter:http://twitter.com/Baahu

--
Twitter:http://twitter.com/Baahu

<elasticsearch.yml>


(Bahubali Jain) #11

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 wrote:

Check if you have any firewall rules on port 9300.

David

Le 29 juin 2012 à 16:44, Baahu 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 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/
:: 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 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/ :: Solr - Lucene - Nutch - ElasticSearch

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

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 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/ :: 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 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/ :: 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/Baahutwitterhttp://twitter.com/Baahu
.com/Baahu http://twitter.com/Baahu

--
Twitter:http:// http://twitter.com/Baahutwitterhttp://twitter.com/Baahu
.com/Baahu http://twitter.com/Baahu

--
Twitter:http:// http://twitter.com/Baahutwitterhttp://twitter.com/Baahu
.com/Baahu http://twitter.com/Baahu

--
Twitter:http://twitter.com/Baahu

<elasticsearch.yml>

--
Twitter:http://twitter.com/Baahu


(David Pilato) #12

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 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 wrote:
Check if you have any firewall rules on port 9300.

David

Le 29 juin 2012 à 16:44, Baahu 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 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/ :: 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 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/ :: Solr - Lucene - Nutch - ElasticSearch

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

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 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/ :: 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 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/ :: 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

--
Twitter:http://twitter.com/Baahu

--
Twitter:http://twitter.com/Baahu

--
Twitter:http://twitter.com/Baahu

<elasticsearch.yml>

--
Twitter:http://twitter.com/Baahu


(Bahubali Jain) #13

No problem that i had actually mentioned in the previous mail:) ...
On Jun 29, 2012 11:07 PM, "David Pilato" 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 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 wrote:

Check if you have any firewall rules on port 9300.

David

Le 29 juin 2012 à 16:44, Baahu 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 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/
:: 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 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/ :: Solr - Lucene - Nutch - ElasticSearch

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

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 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/ :: 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 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/ :: 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/Baahutwitterhttp://twitter.com/Baahu
.com/Baahu http://twitter.com/Baahu

--
Twitter:http:// http://twitter.com/Baahutwitterhttp://twitter.com/Baahu
.com/Baahu http://twitter.com/Baahu

--
Twitter:http:// http://twitter.com/Baahutwitterhttp://twitter.com/Baahu
.com/Baahu http://twitter.com/Baahu

--
Twitter:http://twitter.com/Baahu

<elasticsearch.yml>

--
Twitter:http://twitter.com/Baahu


(David Pilato) #14

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 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 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 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 wrote:
Check if you have any firewall rules on port 9300.

David

Le 29 juin 2012 à 16:44, Baahu 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 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/ :: 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 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/ :: Solr - Lucene - Nutch - ElasticSearch

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

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 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/ :: 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 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/ :: 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

--
Twitter:http://twitter.com/Baahu

--
Twitter:http://twitter.com/Baahu

--
Twitter:http://twitter.com/Baahu

<elasticsearch.yml>

--
Twitter:http://twitter.com/Baahu


(system) #15