I've recently made the switch from elasticsearch 1.7 to 2.0 and I noticed the way you setup the client has changed. I went through the documentation and for some reason the client is always null. I was wondering if I have set it up correctly.
Here is my code:
Client client = null;
try {
client = TransportClient.builder().build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
} catch (Exception e) {
Logger.log(e);
} finally {
client.close();
try {
conn.close();
} catch (SQLException e) {
Logger.log(e);
}
}
The Elasticsearch can be accessed via a standard REST API or Java client libraries for various programming languages. The most obvious thing is the initial option to use the native Elasticsearch client.
Download the latest Elastic Search bundle for your platform. Decompress the package to a convenient location. On UNIX or Linux, spin up the instance with: When you see the logging message started, the node is ready to accept requests. For the Java example, you also need Eclipse and Apache Maven.
Elasticsearch as a project has some interesting outgrowths that might also interest you. In particular, the so-called ELK stack — Elasticsearch, Logstash (for logging management), and Kibana (for reporting/visualization) — is gaining traction.
For example, the Elasticsearch core project is mostly required by the Java High-Level REST Client. It takes and handles the same web request for all input types, and we get the same response objects as the TransportClient, which the server returns. Suppose we have ever used Apache Lucene or Apache Solr.
As noted in the comments, but a little bit more in detail: Elasticsearch 2.0 uses Guava 18.0 (see https://github.com/elastic/elasticsearch/pull/7593). So to fix errors like java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
, make sure to use Guava 18.0 as dependency and not other versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With