1. Never use constructs like " ... = new TransportClient()..." This uses a
new client per call which is very inefficient. Use a singleton per JVM
instead. Do not forget to close the TransportClient thread pool when JVM
shuts down with client.threadPool().close()

2. Use TransportClient settings, you must set the field "cluster.name" with
the cluster name you want to connect to. Otherwise, you won't be able to
connect to any node.

Jörg


On Mon, Aug 11, 2014 at 8:04 PM, Kfeenz <kfeeney5...@gmail.com> wrote:

> So I am very new to elasticsearch... so I apologize in advance..
>
> I started a local instance of elasticsearch and I am trying to connect to
> it through the Java API.
>
> I was under the impression that the transport client was for remote
> clients?
>
> I tried:
>
> @Test
> public void testIndexResponse() {
>
>   Client client = new TransportClient().setTransportAddress(new
> InetSocketTransportAddress("localhost", 9300));
>
>   String json = "{" +
>     "\"user\":\"kimchy\"," +
>     "\"postDate\":\"2013-01-30\"," +
>     "\"message\":\"trying out Elasticsearch\"" +
>     "}";
>
>   IndexResponse response = client.prepareIndex("twitter", "tweet")
>     .setSource(json)
>     .execute()
>     .actionGet();
>
>
>   client.close();
>
>   System.out.println(response.getIndex());
> }
>
> I receive org.elasticsearch.client.transport.NoNodeAvailableException:
> None of the configured nodes are available: [].
>
>
>
>
> On Monday, August 11, 2014 1:19:06 PM UTC-4, Vivek Sachdeva wrote:
>>
>> Have you tried using transport client for connecting...
>>
>> On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:
>>>
>>> All,
>>>
>>> I know this post is old, but I continue to have an issue with this...
>>>
>>> I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z
>>> exception when I run
>>>
>>> Node node = NodeBuilder.nodeBuilder().local(true).node(); // exception
>>> thrown here...
>>> Client client = node.client();
>>>
>>> I have tried including several different slf4j and log4j libraries...
>>>
>>> Right now I have defined in my pom.xml:
>>>
>>> slf4j-api-1.7.7.jar
>>> slf4j-ext-1.7.7.jar
>>> log4j-core-2.0.jar
>>> log4j-api-2.0.jar
>>>
>>> Any suggestions?
>>> log4j-slf4j-impl-2.0.jar
>>>
>>> On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
>>>>
>>>> All
>>>>
>>>> I have a webapp (JAVA) with a list of items on the page. All these
>>>> items are generated on html with session variables. I want to use
>>>> ElasticSearch on the back end to do a search for items with different
>>>> search criteria. Is there a sample I can use it as a resource?
>>>>
>>>> Thanks
>>>>
>>>>  --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elasticsearch+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/f0b50999-be99-4e03-b3ca-e99eb8f9ad4b%40googlegroups.com
> <https://groups.google.com/d/msgid/elasticsearch/f0b50999-be99-4e03-b3ca-e99eb8f9ad4b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAKdsXoH6EqTfLw3ACrbTi9twWw1ojegfo7UtydVp3dfR1dDfvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to