All operations are completely asynchronous in nature.
Meaning they either accept a listener, or return a future.
Using the Java client, one can:
Perform standard index, get, delete and search operations on an existing cluster Perform administrative tasks on a running cluster Start full nodes when you want to run Elasticsearch embedded in your own application or when you want to launch unit or integration testsimport static org.elasticsearch.node.NodeBuilder.*; // on startup Node node = nodeBuilder().node(); Client client = node.client(); // on shutdown node.close();
When you start a Node, it joins an elasticsearch cluster.
Node node = nodeBuilder().clusterName("cluster.name").node(); Client client = node.client();
The transport client connects remotely to an Elasticsearch cluster using the transport module.
It does not join the cluster. Instead, it gets one or more initial transport addresses and communicates with them in round robin fashion on each action.
// on startup Client client = new TransportClient() .addTransportAddress( new InetSocketTransportAddress("host1", 9300)) .addTransportAddress( new InetSocketTransportAddress("host2", 9300)); // on shutdown client.close();
A request to Elasticsearch consists of the same parts as any HTTP request:
curl -X<VERB> '<PROTOCOL>://<HOST>:<PORT>/<PATH>?<QUERY_STRING>' \ -d '<BODY>'
VERB
HTTP method or verb GET, POST, PUT, HEAD, or DELETE
PROTOCOL
HOST
PORT
PATH
QUERY_STRING
BODY