Documenting ElasticSearch Java Client
The current API documentation for the ElasticSearch Java Client is woefully inadequate.
First of all, there is no JavaDoc. Luckily I found some at https://www.javadoc.io/doc/org.elasticsearch/elasticsearch/2.3.0
The tuorials don't provide any of the
import statements, which makes it next to impossible to use.
For example, the TransportClient documentation contains the following code snippet:
// on startup Client client = TransportClient.builder().build() .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host1"), 9300)) .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host2"), 9300)); // on shutdown client.close();
OK - so where do I find
TransportClientBuilder? Through trial-and-error, I found these worked for me to get that code to compile:
import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common.transport.InetSocketTransportAddress;
The GET API documentation is only one line:
GetResponse response = client.prepareGet("twitter", "tweet", "1").get();
But, where does
GetResponse come from? Given the JavaDocs I found above, you can look it up, or here it is: