Hi,
I am new to elastic search and having problem in connecting the node with
Java API.
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "elasticsearch").build();
Client client = new
TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress("localhost", 9200));
I am trying to get the node and create the index on it with this code. And
I am getting Exception on nettyLayer..
Where when it using httpput , I am able to get the index created.
HttpPut httpPut = new HttpPut("http://localhost:9200/data/big/1");
httpPut.addHeader("Accept", "application/json");
httpPut.addHeader("Content-Type",
"application/json");
JSONObject json = new JSONObject();
json.put("name", "testing");
json.put("message", "adding new index");
StringEntity entity = new
StringEntity(json.toString(), "UTF-8");
entity.setContentType("application/json");
httpPut.setEntity(entity);
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient
.execute(httpPut);
Please help me out in this regard.
Disclaimer: The information contained in this message and attachments is
intended solely for the attention and use of the named addressee and may be
confidential. If you are not the intended recipient, you are reminded that
the information remains the property of the sender. You must not use,
disclose, distribute, copy, print or rely on this e-mail. If you have
received this message in error, please contact the sender immediately and
irrevocably delete this message and any copies.
Hi,
I am new to Elasticsearch and having problem in connecting the node with
Java API.
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "elasticsearch").build();
Client client = new
TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress("localhost", 9200));
I am trying to get the node and create the index on it with this code.
And I am getting Exception on nettyLayer..
Where when it using httpput , I am able to get the index created.
HttpPut httpPut = new HttpPut("http://localhost:9200/data/big/1");
httpPut.addHeader("Accept",
"application/json");
httpPut.addHeader("Content-Type",
"application/json");
JSONObject json = new JSONObject();
json.put("name", "testing");
json.put("message", "adding new index");
StringEntity entity = new
StringEntity(json.toString(), "UTF-8");
entity.setContentType("application/json");
httpPut.setEntity(entity);
HttpClient httpClient = new
DefaultHttpClient();
HttpResponse response = httpClient
.execute(httpPut);
Please help me out in this regard.
Disclaimer: The information contained in this message and attachments is
intended solely for the attention and use of the named addressee and may be
confidential. If you are not the intended recipient, you are reminded that
the information remains the property of the sender. You must not use,
disclose, distribute, copy, print or rely on this e-mail. If you have
received this message in error, please contact the sender immediately and
irrevocably delete this message and any copies.
Hi,
I am new to Elasticsearch and having problem in connecting the node with
Java API.
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "elasticsearch").build();
Client client = new
TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress("localhost", 9200));
I am trying to get the node and create the index on it with this code.
And I am getting Exception on nettyLayer..
Where when it using httpput , I am able to get the index created.
HttpPut httpPut = new HttpPut("http://localhost:9200/data/big/1");
httpPut.addHeader("Accept",
"application/json");
httpPut.addHeader("Content-Type",
"application/json");
JSONObject json = new JSONObject();
json.put("name", "testing");
json.put("message", "adding new index");
StringEntity entity = new
StringEntity(json.toString(), "UTF-8");
entity.setContentType("application/json");
httpPut.setEntity(entity);
HttpClient httpClient = new
DefaultHttpClient();
HttpResponse response = httpClient
.execute(httpPut);
Please help me out in this regard.
What Robin means to say is that you should be using the Elasticsearch
Java API, and not use other REST/web libraries, even if they are in
Java.
There is no need for HttpPut, HttpClient, etc... Simple use the
methods defined in org.elasticsearch.client.Client. The guide could do
a better job at providing a front to back usage of the client object,
but the basics are there. Take a look at creating an index using the
Java API:
The mailing list has tons of examples, and while it might be hard to
search for code, you should still find something. Hopefully this can
be a start.
Disclaimer: The information contained in this message and attachments is
intended solely for the attention and use of the named addressee and may be
confidential. If you are not the intended recipient, you are reminded that
the information remains the property of the sender. You must not use,
disclose, distribute, copy, print or rely on this e-mail. If you have
received this message in error, please contact the sender immediately and
irrevocably delete this message and any copies.
Hi,
I am new to Elasticsearch and having problem in connecting the node with
Java API.
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "elasticsearch").build();
Client client = new
TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress("localhost", 9200));
I am trying to get the node and create the index on it with this code.
And I am getting Exception on nettyLayer..
Where when it using httpput , I am able to get the index created.
HttpPut httpPut = new HttpPut("http://localhost:9200/data/big/1");
httpPut.addHeader("Accept",
"application/json");
httpPut.addHeader("Content-Type",
"application/json");
JSONObject json = new JSONObject();
json.put("name", "testing");
json.put("message", "adding new index");
StringEntity entity = new
StringEntity(json.toString(), "UTF-8");
entity.setContentType("application/json");
httpPut.setEntity(entity);
HttpClient httpClient = new
DefaultHttpClient();
HttpResponse response = httpClient
.execute(httpPut);
Please help me out in this regard.
On Tuesday, September 18, 2012 6:43:01 PM UTC+2, ali ilyas wrote:
Hi,
I am new to Elasticsearch and having problem in connecting the node with
Java API.
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "elasticsearch").build();
Client client = new
TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress("localhost", 9200));
I am trying to get the node and create the index on it with this code.
And I am getting Exception on nettyLayer..
Where when it using httpput , I am able to get the index created.
HttpPut httpPut = new HttpPut("http://localhost:9200/data/big/1");
httpPut.addHeader("Accept",
"application/json");
httpPut.addHeader("Content-Type",
"application/json");
JSONObject json = new JSONObject();
json.put("name", "testing");
json.put("message", "adding new index");
StringEntity entity = new
StringEntity(json.toString(), "UTF-8");
entity.setContentType("application/json");
httpPut.setEntity(entity);
HttpClient httpClient = new
DefaultHttpClient();
HttpResponse response = httpClient
.execute(httpPut);
Please help me out in this regard.
use JEST if you really want to some of the functionality of Apache HttpClient. In a project, i had a need to send custom headers, JEST had that capability plus the query building of the regular ES client API.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.