Revert "Removing old documentation mentioning NodeBuilder."
This reverts commit 3ca02d647e
.
This commit is contained in:
parent
3ca02d647e
commit
21e94e6054
|
@ -0,0 +1,59 @@
|
|||
[[client]]
|
||||
== Client
|
||||
|
||||
Obtaining an elasticsearch Groovy `GClient` (a `GClient` is a simple
|
||||
wrapper on top of the Java `Client`) is simple. The most common way to
|
||||
get a client is by starting an embedded `Node` which acts as a node
|
||||
within the cluster.
|
||||
|
||||
|
||||
[[node-client]]
|
||||
=== Node Client
|
||||
|
||||
A Node based client is the simplest form to get a `GClient` to start
|
||||
executing operations against elasticsearch.
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
import org.elasticsearch.groovy.client.GClient
|
||||
import org.elasticsearch.groovy.node.GNode
|
||||
import static org.elasticsearch.groovy.node.GNodeBuilder.nodeBuilder
|
||||
|
||||
// on startup
|
||||
|
||||
GNode node = nodeBuilder().node();
|
||||
GClient client = node.client();
|
||||
|
||||
// on shutdown
|
||||
|
||||
node.close();
|
||||
--------------------------------------------------
|
||||
|
||||
Since elasticsearch allows to configure it using JSON based settings,
|
||||
the configuration itself can be done using a closure that represent the
|
||||
JSON:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
import org.elasticsearch.groovy.node.GNode
|
||||
import org.elasticsearch.groovy.node.GNodeBuilder
|
||||
import static org.elasticsearch.groovy.node.GNodeBuilder.*
|
||||
|
||||
// on startup
|
||||
|
||||
GNodeBuilder nodeBuilder = nodeBuilder();
|
||||
nodeBuilder.settings {
|
||||
node {
|
||||
client = true
|
||||
}
|
||||
cluster {
|
||||
name = "test"
|
||||
}
|
||||
}
|
||||
|
||||
GNode node = nodeBuilder.node()
|
||||
|
||||
// on shutdown
|
||||
|
||||
node.stop().close()
|
||||
--------------------------------------------------
|
Loading…
Reference in New Issue