Java Client

I am a newbie in Elasticsearch. I am trying to create a Java client
that connects to the Elasticsearch version 0.19.0 started via Cygwin.

Below is my sample code:

public static void main(String[] args) {

	Node node = nodeBuilder().client(true).node();
	Client client = new TransportClient()
			.addTransportAddress(new InetSocketTransportAddress(
					"127.0.0.1", 9300));
	try {
		IndexResponse response = client
				.prepareIndex("twitter", "tweet", "1")
				.setSource(
						jsonBuilder()
								.startObject()
								.field("user", "kimchy")
								.field("postDate", new Date())
								.field("message",
										"trying out Elastic Search")
								.endObject()).execute().actionGet();
	} catch (ElasticSearchException e) {

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

		e.printStackTrace();
	}

	node.close();

}

However, when I run this test, I get the following error from running
"Node node = nodeBuilder().client(true).node();"

[2012-03-13 00:34:18,712][WARN ][discovery.zen.ping.multicast] [Pitt,
Desmond] failed to read requesting data from
org.elasticsearch.ElasticSearchIllegalStateException: failed
multicastmessage, probably message from previous version at
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing
$Receiver.run(MulticastZenPing.java:406) at
java.lang.Thread.run(Thread.java:722)

What did I do wrong?

Thanks!

There's two way to connect to an ES cluster.

  1. You start a client node and then ask the node to give you a client.
  2. You create a simple transport client

Here you mixes the two ways.

If you want to use a node, your second line should be :
Client client = node . client ();

Did you modify settings for your ES node started with cygwin ?
BTW, why don't you start it with the windows elasticsearch command line ?

HTH
David.

Le 13 mars 2012 à 08:43, ksquare ksquaredot@gmail.com a écrit :

I am a newbie in Elasticsearch. I am trying to create a Java client
that connects to the Elasticsearch version 0.19.0 started via Cygwin.

Below is my sample code:

    public static void main(String[] args) {

            Node node = nodeBuilder().client(true).node();
            Client client = new TransportClient()
                            .addTransportAddress(new

InetSocketTransportAddress(

                                            "127.0.0.1", 9300));
            try {
                    IndexResponse response = client
                                    .prepareIndex("twitter", "tweet",

"1")

                                    .setSource(
                                                    jsonBuilder()

.startObject()

.field("user", "kimchy")

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

.field("message",

          "trying out Elastic Search")

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

            } catch (ElasticSearchException e) {

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

                    e.printStackTrace();
            }

            node.close();

    }

However, when I run this test, I get the following error from running
"Node node = nodeBuilder().client(true).node();"

[2012-03-13 00:34:18,712][WARN ][discovery.zen.ping.multicast] [Pitt,
Desmond] failed to read requesting data from
org.elasticsearch.ElasticSearchIllegalStateException: failed
multicastmessage, probably message from previous version at
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing
$Receiver.run(MulticastZenPing.java:406) at
java.lang.Thread.run(Thread.java:722)

What did I do wrong?

Thanks!

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

Thanks for your help!

I started elasticsearch with windows and changed my first and second lines
of code. Now I have

public static void main(String[] args) {
    Node node = nodeBuilder().node();
    Client client = node.client (); 
    try {
        IndexResponse response = client
                .prepareIndex("twitter", "tweet", "1")
                .setSource(
                        jsonBuilder()
                                .startObject()
                                .field("user", "kimchy")
                                .field("postDate", new Date())
                                .field("message",
                                        "trying out Elastic Search")
                                .endObject()).execute().actionGet();
    } catch (ElasticSearchException e) {

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

        e.printStackTrace();
    }

    node.close();

}

However, when I run it, I got the following error in my java console:

INFO: [Achilles] {elasticsearch/0.16.0}[5864]: started
Mar 14, 2012 12:00:32 AM org.elasticsearch.common.lucene
WARNING: Failed to doc writer fields
java.lang.NoSuchFieldException: rollbackSegmentInfos
at java.lang.Class.getDeclaredField(Unknown Source)
at
org.elasticsearch.common.lucene.IndexWriters.(IndexWriters.java:43)
at
org.elasticsearch.index.engine.robin.RobinEngine.newTransactionLogId(RobinEngine.java:1060)
at
org.elasticsearch.index.engine.robin.RobinEngine.start(RobinEngine.java:230)
at
org.elasticsearch.index.shard.service.InternalIndexShard.performRecoveryPrepareForTranslog(InternalIndexShard.java:480)
at
org.elasticsearch.index.gateway.local.LocalIndexShardGateway.recover(LocalIndexShardGateway.java:143)
at
org.elasticsearch.index.gateway.IndexShardGatewayService$1.run(IndexShardGatewayService.java:144)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

What does java.lang.NoSuchFieldException: rollbackSegmentInfos mean?

Also in my windows console, I still get the following. What does it mean?

org.elasticsearch.ElasticSearchIllegalStateException: failed multicast
message, probably message from previous version
at
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing$Receiver.run(MulticastZenPing.java:406)
at java.lang.Thread.run(Thread.java:722)
[2012-03-14 00:00:29,814][WARN ][discovery.zen.ping.multicast] [DJ] failed
to read requesting data
org.elasticsearch.ElasticSearchIllegalStateException: failed multicast
message, probably message from previous version
at
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing$Receiver.run(MulticastZenPing.java:406)
at java.lang.Thread.run(Thread.java:722)

Thanks!

On Tuesday, March 13, 2012 12:57:59 AM UTC-7, David Pilato wrote:

There's two way to connect to an ES cluster.

  1. You start a client node and then ask the node to give you a client.

  2. You create a simple transport client

Here you mixes the two ways.

If you want to use a node, your second line should be :

Client client = node . client ();

Did you modify settings for your ES node started with cygwin ?

BTW, why don't you start it with the windows elasticsearch command line ?

HTH

David.

Le 13 mars 2012 à 08:43, ksquare ksquaredot@gmail.com a écrit :

I am a newbie in Elasticsearch. I am trying to create a Java client
that connects to the Elasticsearch version 0.19.0 started via Cygwin.

Below is my sample code:

    public static void main(String[] args) { 

            Node node = nodeBuilder().client(true).node(); 
            Client client = new TransportClient() 
                            .addTransportAddress(new 

InetSocketTransportAddress(

                                            "127.0.0.1", 9300)); 
            try { 
                    IndexResponse response = client 
                                    .prepareIndex("twitter", 

"tweet", "1")

                                    .setSource( 
                                                    jsonBuilder() 

.startObject()

.field("user", "kimchy")

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

.field("message",

           "trying out Elastic Search") 

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

            } catch (ElasticSearchException e) { 

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

                    e.printStackTrace(); 
            } 

            node.close(); 

    } 

However, when I run this test, I get the following error from running
"Node node = nodeBuilder().client(true).node();"

[2012-03-13 00:34:18,712][WARN ][discovery.zen.ping.multicast] [Pitt,
Desmond] failed to read requesting data from
org.elasticsearch.ElasticSearchIllegalStateException: failed
multicastmessage, probably message from previous version at
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing
$Receiver.run(MulticastZenPing.java:406) at
java.lang.Thread.run(Thread.java:722)

What did I do wrong?

Thanks!

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

Are you sure you are using the correct versions (of elasticsearch with relevant Lucene version)? The rollbackSegmentsInfos message can be ignore...

On Wednesday, March 14, 2012 at 9:07 AM, ksquare wrote:

Thanks for your help!

I started elasticsearch with windows and changed my first and second lines of code. Now I have

public static void main(String[] args) {
    Node node = nodeBuilder().node();
    Client client = node.client ();  
    try {
        IndexResponse response = client
                .prepareIndex("twitter", "tweet", "1")
                .setSource(
                        jsonBuilder()
                                .startObject()
                                .field("user", "kimchy")
                                .field("postDate", new Date())
                                .field("message",
                                        "trying out Elastic Search")
                                .endObject()).execute().actionGet();
    } catch (ElasticSearchException e) {

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

        e.printStackTrace();
    }

    node.close();

}

However, when I run it, I got the following error in my java console:

INFO: [Achilles] {elasticsearch/0.16.0}[5864]: started
Mar 14, 2012 12:00:32 AM org.elasticsearch.common.lucene
WARNING: Failed to doc writer fields
java.lang.NoSuchFieldException: rollbackSegmentInfos
at java.lang.Class.getDeclaredField(Unknown Source)
at org.elasticsearch.common.lucene.IndexWriters.(IndexWriters.java:43)
at org.elasticsearch.index.engine.robin.RobinEngine.newTransactionLogId(RobinEngine.java:1060)
at org.elasticsearch.index.engine.robin.RobinEngine.start(RobinEngine.java:230)
at org.elasticsearch.index.shard.service.InternalIndexShard.performRecoveryPrepareForTranslog(InternalIndexShard.java:480)
at org.elasticsearch.index.gateway.local.LocalIndexShardGateway.recover(LocalIndexShardGateway.java:143)
at org.elasticsearch.index.gateway.IndexShardGatewayService$1.run(IndexShardGatewayService.java:144)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

What does java.lang.NoSuchFieldException: rollbackSegmentInfos mean?

Also in my windows console, I still get the following. What does it mean?

org.elasticsearch.ElasticSearchIllegalStateException: failed multicast message, probably message from previous version
at org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing$Receiver.run(MulticastZenPing.java:406)
at java.lang.Thread.run(Thread.java:722)
[2012-03-14 00:00:29,814][WARN ][discovery.zen.ping.multicast] [DJ] failed to read requesting data
org.elasticsearch.ElasticSearchIllegalStateException: failed multicast message, probably message from previous version
at org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing$Receiver.run(MulticastZenPing.java:406)
at java.lang.Thread.run(Thread.java:722)

Thanks!

On Tuesday, March 13, 2012 12:57:59 AM UTC-7, David Pilato wrote:

There's two way to connect to an ES cluster.

  1. You start a client node and then ask the node to give you a client.

  2. You create a simple transport client

Here you mixes the two ways.

If you want to use a node, your second line should be :

Client client = node . client ();

Did you modify settings for your ES node started with cygwin ?

BTW, why don't you start it with the windows elasticsearch command line ?

HTH

David.

Le 13 mars 2012 à 08:43, ksquare <ksquaredot@gmail.com (mailto:ksquaredot@gmail.com)> a écrit :

I am a newbie in Elasticsearch. I am trying to create a Java client
that connects to the Elasticsearch version 0.19.0 started via Cygwin.

Below is my sample code:

    public static void main(String[] args) {  

            Node node = nodeBuilder().client(true).node();  
            Client client = new TransportClient()  
                            .addTransportAddress(new InetSocketTransportAddress(  
                                            "127.0.0.1", 9300));  
            try {  
                    IndexResponse response = client  
                                    .prepareIndex("twitter", "tweet", "1")  
                                    .setSource(  
                                                    jsonBuilder()  
                                                                    .startObject()  
                                                                    .field("user", "kimchy")  
                                                                    .field("postDate", new Date())  
                                                                    .field("message",  
                                                                                    "trying out Elastic Search")  
                                                                    .endObject()).execute().actionGet();  
            } catch (ElasticSearchException e) {  

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

                    e.printStackTrace();  
            }  

            node.close();  

    }  

However, when I run this test, I get the following error from running
"Node node = nodeBuilder().client(true).node();"

[2012-03-13 00:34:18,712][WARN ][discovery.zen.ping.multicast] [Pitt,
Desmond] failed to read requesting data from
org.elasticsearch.ElasticSearchIllegalStateException: failed
multicastmessage, probably message from previous version at
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing
$Receiver.run(MulticastZenPing.java:406) at
java.lang.Thread.run(Thread.java:722)

What did I do wrong?

Thanks!

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

I am using elasticsearch 0.19.0, what Lucene dependencies do I need to
include in my Maven pom.xml file?

Thanks!

On Wednesday, March 14, 2012 5:39:20 AM UTC-7, kimchy wrote:

Are you sure you are using the correct versions (of elasticsearch with
relevant Lucene version)? The rollbackSegmentsInfos message can be
ignore...

On Wednesday, March 14, 2012 at 9:07 AM, ksquare wrote:

Thanks for your help!

I started elasticsearch with windows and changed my first and second lines
of code. Now I have

public static void main(String[] args) {
    Node node = nodeBuilder().node();
    Client client = node.client (); 
    try {
        IndexResponse response = client
                .prepareIndex("twitter", "tweet", "1")
                .setSource(
                        jsonBuilder()
                                .startObject()
                                .field("user", "kimchy")
                                .field("postDate", new Date())
                                .field("message",
                                        "trying out Elastic Search")
                                .endObject()).execute().actionGet();
    } catch (ElasticSearchException e) {

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

        e.printStackTrace();
    }

    node.close();

}

However, when I run it, I got the following error in my java console:

INFO: [Achilles] {elasticsearch/0.16.0}[5864]: started
Mar 14, 2012 12:00:32 AM org.elasticsearch.common.lucene
WARNING: Failed to doc writer fields
java.lang.NoSuchFieldException: rollbackSegmentInfos
at java.lang.Class.getDeclaredField(Unknown Source)
at
org.elasticsearch.common.lucene.IndexWriters.(IndexWriters.java:43)
at
org.elasticsearch.index.engine.robin.RobinEngine.newTransactionLogId(RobinEngine.java:1060)
at
org.elasticsearch.index.engine.robin.RobinEngine.start(RobinEngine.java:230)
at
org.elasticsearch.index.shard.service.InternalIndexShard.performRecoveryPrepareForTranslog(InternalIndexShard.java:480)
at
org.elasticsearch.index.gateway.local.LocalIndexShardGateway.recover(LocalIndexShardGateway.java:143)
at
org.elasticsearch.index.gateway.IndexShardGatewayService$1.run(IndexShardGatewayService.java:144)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

What does java.lang.NoSuchFieldException: rollbackSegmentInfos mean?

Also in my windows console, I still get the following. What does it mean?

org.elasticsearch.ElasticSearchIllegalStateException: failed multicast
message, probably message from previous version
at
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing$Receiver.run(MulticastZenPing.java:406)
at java.lang.Thread.run(Thread.java:722)
[2012-03-14 00:00:29,814][WARN ][discovery.zen.ping.multicast] [DJ] failed
to read requesting data
org.elasticsearch.ElasticSearchIllegalStateException: failed multicast
message, probably message from previous version
at
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing$Receiver.run(MulticastZenPing.java:406)
at java.lang.Thread.run(Thread.java:722)

Thanks!

On Tuesday, March 13, 2012 12:57:59 AM UTC-7, David Pilato wrote:

There's two way to connect to an ES cluster.

  1. You start a client node and then ask the node to give you a client.

  2. You create a simple transport client

Here you mixes the two ways.

If you want to use a node, your second line should be :

Client client = node . client ();

Did you modify settings for your ES node started with cygwin ?

BTW, why don't you start it with the windows elasticsearch command line ?

HTH

David.

Le 13 mars 2012 à 08:43, ksquare ksquaredot@gmail.com a écrit :

I am a newbie in Elasticsearch. I am trying to create a Java client
that connects to the Elasticsearch version 0.19.0 started via Cygwin.

Below is my sample code:

    public static void main(String[] args) { 

            Node node = nodeBuilder().client(true).node(); 
            Client client = new TransportClient() 
                            .addTransportAddress(new 

InetSocketTransportAddress(

                                            "127.0.0.1", 9300)); 
            try { 
                    IndexResponse response = client 
                                    .prepareIndex("twitter", 

"tweet", "1")

                                    .setSource( 
                                                    jsonBuilder() 

.startObject()

.field("user", "kimchy")

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

.field("message",

           "trying out Elastic Search") 

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

            } catch (ElasticSearchException e) { 

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

                    e.printStackTrace(); 
            } 

            node.close(); 

    } 

However, when I run this test, I get the following error from running
"Node node = nodeBuilder().client(true).node();"

[2012-03-13 00:34:18,712][WARN ][discovery.zen.ping.multicast] [Pitt,
Desmond] failed to read requesting data from
org.elasticsearch.ElasticSearchIllegalStateException: failed
multicastmessage, probably message from previous version at
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing
$Receiver.run(MulticastZenPing.java:406) at
java.lang.Thread.run(Thread.java:722)

What did I do wrong?

Thanks!

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

0.19.0 uses Lucene 3.5, which is part of the elasticsearch pom.xml. Make
sure you don't have several jar versions (of either elasticsearch or
Lucene).

On Wed, Mar 14, 2012 at 9:54 PM, ksquare ksquaredot@gmail.com wrote:

I am using elasticsearch 0.19.0, what Lucene dependencies do I need to
include in my Maven pom.xml file?

Thanks!

On Wednesday, March 14, 2012 5:39:20 AM UTC-7, kimchy wrote:

Are you sure you are using the correct versions (of elasticsearch with
relevant Lucene version)? The rollbackSegmentsInfos message can be
ignore...

On Wednesday, March 14, 2012 at 9:07 AM, ksquare wrote:

Thanks for your help!

I started elasticsearch with windows and changed my first and second
lines of code. Now I have

public static void main(String[] args) {
    Node node = nodeBuilder().node();
    Client client = node.client ();
    try {
        IndexResponse response = client
                .prepareIndex("twitter", "tweet", "1")
                .setSource(
                        jsonBuilder()
                                .startObject()
                                .field("user", "kimchy")
                                .field("postDate", new Date())
                                .field("message",
                                        "trying out Elastic Search")
                                .endObject()).execute().**

actionGet();
} catch (ElasticSearchException e) {

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

        e.printStackTrace();
    }

    node.close();

}

However, when I run it, I got the following error in my java console:

INFO: [Achilles] {elasticsearch/0.16.0}[5864]: started
Mar 14, 2012 12:00:32 AM org.elasticsearch.common.**lucene
WARNING: Failed to doc writer fields
java.lang.**NoSuchFieldException: rollbackSegmentInfos
at java.lang.Class.**getDeclaredField(Unknown Source)
at org.elasticsearch.common.lucene.IndexWriters.(
IndexWriters.java:43)
at org.elasticsearch.index.engine.robin.RobinEngine.
newTransactionLogId(RobinEngine.java:1060)
at org.elasticsearch.index.engine.robin.RobinEngine.
start(RobinEngine.java:230)
at org.elasticsearch.index.shard.service.InternalIndexShard.
performRecoveryPrepareForTrans
log(InternalIndexShard.java:**480)
at org.elasticsearch.index.**gateway.local.*LocalIndexShardGateway.
*recover(**LocalIndexShardGateway.java:**143)
at org.elasticsearch.index.**gateway.IndexShardGatewayService$1.
run(IndexShardGatewayService.**java:144)
at java.util.concurrent.**ThreadPoolExecutor.runWorker(**Unknown
Source)
at java.util.concurrent.**ThreadPoolExecutor$Worker.run(**Unknown
Source)
at java.lang.Thread.run(Unknown Source)

What does java.lang.**NoSuchFieldException: rollbackSegmentInfos mean?

Also in my windows console, I still get the following. What does it mean?

org.elasticsearch.ElasticSearchIllegalStateException: failed
multicast message, probably message from previous version
at org.elasticsearch.discovery.zen.ping.multicast.
MulticastZenPing$Receiver.run(**MulticastZenPing.java:406)
at java.lang.Thread.run(Thread.**java:722)
[2012-03-14 00:00:29,814][WARN ][discovery.zen.ping.**multicast] [DJ]
failed to read requesting data
org.elasticsearch.ElasticSearchIllegalStateException: failed
multicast message, probably message from previous version
at org.elasticsearch.discovery.zen.ping.multicast.
MulticastZenPing$Receiver.run(**MulticastZenPing.java:406)
at java.lang.Thread.run(Thread.**java:722)

Thanks!

On Tuesday, March 13, 2012 12:57:59 AM UTC-7, David Pilato wrote:

There's two way to connect to an ES cluster.

  1. You start a client node and then ask the node to give you a client.

  2. You create a simple transport client

Here you mixes the two ways.

If you want to use a node, your second line should be :

Client client = node . client ();

Did you modify settings for your ES node started with cygwin ?

BTW, why don't you start it with the windows elasticsearch command line
?

HTH

David.

Le 13 mars 2012 à 08:43, ksquare ksquaredot@gmail.com a écrit :

I am a newbie in Elasticsearch. I am trying to create a Java client
that connects to the Elasticsearch version 0.19.0 started via Cygwin.

Below is my sample code:

    public static void main(String[] args) {

            Node node = nodeBuilder().client(true).**node();
            Client client = new TransportClient()
                            .addTransportAddress(new

InetSocketTransportAddress(

                                            "127.0.0.1", 9300));
            try {
                    IndexResponse response = client
                                    .prepareIndex("twitter",

"tweet", "1")

                                    .setSource(
                                                    jsonBuilder()

.startObject()

.field("user", "kimchy")

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

.field("message",

             "trying out Elastic Search")

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

            } catch (ElasticSearchException e) {

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

                    e.printStackTrace();
            }

            node.close();

    }

However, when I run this test, I get the following error from running
"Node node = nodeBuilder().client(true).**node();"

[2012-03-13 00:34:18,712][WARN ][discovery.zen.ping.**multicast]
[Pitt,
Desmond] failed to read requesting data from
org.elasticsearch.ElasticSearchIllegalStateException: failed
multicastmessage, probably message from previous version at
org.elasticsearch.discovery.**zen.ping.multicast.**MulticastZenPing
$Receiver.run(**MulticastZenPing.java:406) at
java.lang.Thread.run(Thread.**java:722)

What did I do wrong?

Thanks!

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet