cleaned Groovy classes * added type information to public methods * removed semicolons * replaced GStrings with Strings
This commit is contained in:
parent
0eaccd483f
commit
5f4c6c75ae
|
@ -24,14 +24,14 @@ package org.elasticsearch.groovy.client
|
||||||
*/
|
*/
|
||||||
class GAdminClient {
|
class GAdminClient {
|
||||||
|
|
||||||
private final GClient gClient;
|
private final GClient gClient
|
||||||
|
|
||||||
final GIndicesAdminClient indices;
|
final GIndicesAdminClient indices
|
||||||
|
|
||||||
final GClusterAdminClient cluster;
|
final GClusterAdminClient cluster
|
||||||
|
|
||||||
def GAdminClient(gClient) {
|
GAdminClient(gClient) {
|
||||||
this.gClient = gClient;
|
this.gClient = gClient
|
||||||
|
|
||||||
this.indices = new GIndicesAdminClient(gClient)
|
this.indices = new GIndicesAdminClient(gClient)
|
||||||
this.cluster = new GClusterAdminClient(gClient)
|
this.cluster = new GClusterAdminClient(gClient)
|
||||||
|
|
|
@ -54,8 +54,8 @@ class GClient {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BaseRequestBuilder.metaClass.gexecute = {
|
BaseRequestBuilder.metaClass.gexecute = {
|
||||||
ListenableActionFuture future = delegate.execute();
|
ListenableActionFuture future = delegate.execute()
|
||||||
return new GActionFuture(future);
|
return new GActionFuture(future)
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexRequest.metaClass.setSource = {Closure c ->
|
IndexRequest.metaClass.setSource = {Closure c ->
|
||||||
|
@ -148,31 +148,31 @@ class GClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XContentType contentType = XContentType.SMILE;
|
public static XContentType contentType = XContentType.SMILE
|
||||||
|
|
||||||
public static XContentType indexContentType = XContentType.JSON;
|
public static XContentType indexContentType = XContentType.JSON
|
||||||
|
|
||||||
final Client client;
|
final Client client
|
||||||
|
|
||||||
int resolveStrategy = Closure.DELEGATE_FIRST
|
int resolveStrategy = Closure.DELEGATE_FIRST
|
||||||
|
|
||||||
private final InternalClient internalClient
|
private final InternalClient internalClient
|
||||||
|
|
||||||
final GAdminClient admin;
|
final GAdminClient admin
|
||||||
|
|
||||||
def GClient(client) {
|
GClient(client) {
|
||||||
this.client = client;
|
this.client = client
|
||||||
this.internalClient = client;
|
this.internalClient = client
|
||||||
|
|
||||||
this.admin = new GAdminClient(this)
|
this.admin = new GAdminClient(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexRequestBuilder prepareIndex(String index, String type) {
|
IndexRequestBuilder prepareIndex(String index, String type) {
|
||||||
return client.prepareIndex(index, type);
|
return client.prepareIndex(index, type)
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexRequestBuilder prepareIndex(String index, String type, String id) {
|
IndexRequestBuilder prepareIndex(String index, String type, String id) {
|
||||||
return client.prepareIndex(index, type, id);
|
return client.prepareIndex(index, type, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<IndexResponse> index(Closure c) {
|
GActionFuture<IndexResponse> index(Closure c) {
|
||||||
|
@ -184,7 +184,7 @@ class GClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<IndexResponse> index(IndexRequest request) {
|
GActionFuture<IndexResponse> index(IndexRequest request) {
|
||||||
GActionFuture<IndexResponse> future = new GActionFuture<IndexResponse>(internalClient.threadPool(), request);
|
GActionFuture<IndexResponse> future = new GActionFuture<IndexResponse>(internalClient.threadPool(), request)
|
||||||
client.index(request, future)
|
client.index(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ class GClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GetRequestBuilder prepareGet(String index, String type, String id) {
|
GetRequestBuilder prepareGet(String index, String type, String id) {
|
||||||
return client.prepareGet(index, type, id);
|
return client.prepareGet(index, type, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<GetResponse> get(Closure c) {
|
GActionFuture<GetResponse> get(Closure c) {
|
||||||
|
@ -206,7 +206,7 @@ class GClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<GetResponse> get(GetRequest request) {
|
GActionFuture<GetResponse> get(GetRequest request) {
|
||||||
GActionFuture<GetResponse> future = new GActionFuture<GetResponse>(internalClient.threadPool(), request);
|
GActionFuture<GetResponse> future = new GActionFuture<GetResponse>(internalClient.threadPool(), request)
|
||||||
client.get(request, future)
|
client.get(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ class GClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<DeleteResponse> delete(DeleteRequest request) {
|
GActionFuture<DeleteResponse> delete(DeleteRequest request) {
|
||||||
GActionFuture<DeleteResponse> future = new GActionFuture<DeleteResponse>(internalClient.threadPool(), request);
|
GActionFuture<DeleteResponse> future = new GActionFuture<DeleteResponse>(internalClient.threadPool(), request)
|
||||||
client.delete(request, future)
|
client.delete(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ class GClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteByQueryRequestBuilder prepareDeleteByQuery(String... indices) {
|
DeleteByQueryRequestBuilder prepareDeleteByQuery(String... indices) {
|
||||||
return client.prepareDeleteByQuery(indices);
|
return client.prepareDeleteByQuery(indices)
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<DeleteByQueryResponse> deleteByQuery(Closure c) {
|
GActionFuture<DeleteByQueryResponse> deleteByQuery(Closure c) {
|
||||||
|
@ -250,7 +250,7 @@ class GClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<DeleteByQueryResponse> deleteByQuery(DeleteByQueryRequest request) {
|
GActionFuture<DeleteByQueryResponse> deleteByQuery(DeleteByQueryRequest request) {
|
||||||
GActionFuture<DeleteByQueryResponse> future = new GActionFuture<DeleteByQueryResponse>(internalClient.threadPool(), request);
|
GActionFuture<DeleteByQueryResponse> future = new GActionFuture<DeleteByQueryResponse>(internalClient.threadPool(), request)
|
||||||
client.deleteByQuery(request, future)
|
client.deleteByQuery(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ class GClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<CountResponse> count(CountRequest request) {
|
GActionFuture<CountResponse> count(CountRequest request) {
|
||||||
GActionFuture<CountResponse> future = new GActionFuture<CountResponse>(internalClient.threadPool(), request);
|
GActionFuture<CountResponse> future = new GActionFuture<CountResponse>(internalClient.threadPool(), request)
|
||||||
client.count(request, future)
|
client.count(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ class GClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<SearchResponse> search(SearchRequest request) {
|
GActionFuture<SearchResponse> search(SearchRequest request) {
|
||||||
GActionFuture<SearchResponse> future = new GActionFuture<SearchResponse>(internalClient.threadPool(), request);
|
GActionFuture<SearchResponse> future = new GActionFuture<SearchResponse>(internalClient.threadPool(), request)
|
||||||
client.search(request, future)
|
client.search(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ class GClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<SearchResponse> moreLikeThis(MoreLikeThisRequest request) {
|
GActionFuture<SearchResponse> moreLikeThis(MoreLikeThisRequest request) {
|
||||||
GActionFuture<SearchResponse> future = new GActionFuture<SearchResponse>(internalClient.threadPool(), request);
|
GActionFuture<SearchResponse> future = new GActionFuture<SearchResponse>(internalClient.threadPool(), request)
|
||||||
client.moreLikeThis(request, future)
|
client.moreLikeThis(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,14 +49,14 @@ class GClusterAdminClient {
|
||||||
|
|
||||||
private final GClient gClient
|
private final GClient gClient
|
||||||
|
|
||||||
private final InternalClient internalClient;
|
private final InternalClient internalClient
|
||||||
|
|
||||||
final ClusterAdminClient clusterAdminClient;
|
final ClusterAdminClient clusterAdminClient
|
||||||
|
|
||||||
def GClusterAdminClient(gClient) {
|
def GClusterAdminClient(gClient) {
|
||||||
this.gClient = gClient;
|
this.gClient = gClient
|
||||||
this.internalClient = gClient.client;
|
this.internalClient = gClient.client
|
||||||
this.clusterAdminClient = internalClient.admin().cluster();
|
this.clusterAdminClient = internalClient.admin().cluster()
|
||||||
}
|
}
|
||||||
|
|
||||||
// HEALTH
|
// HEALTH
|
||||||
|
@ -74,7 +74,7 @@ class GClusterAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<ClusterHealthResponse> health(ClusterHealthRequest request) {
|
GActionFuture<ClusterHealthResponse> health(ClusterHealthRequest request) {
|
||||||
GActionFuture<ClusterHealthResponse> future = new GActionFuture<ClusterHealthResponse>(internalClient.threadPool(), request);
|
GActionFuture<ClusterHealthResponse> future = new GActionFuture<ClusterHealthResponse>(internalClient.threadPool(), request)
|
||||||
clusterAdminClient.health(request, future)
|
clusterAdminClient.health(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ class GClusterAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<ClusterStateResponse> state(ClusterStateRequest request) {
|
GActionFuture<ClusterStateResponse> state(ClusterStateRequest request) {
|
||||||
GActionFuture<ClusterStateResponse> future = new GActionFuture<ClusterStateResponse>(internalClient.threadPool(), request);
|
GActionFuture<ClusterStateResponse> future = new GActionFuture<ClusterStateResponse>(internalClient.threadPool(), request)
|
||||||
clusterAdminClient.state(request, future)
|
clusterAdminClient.state(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ class GClusterAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<NodesInfoResponse> nodesInfo(NodesInfoRequest request) {
|
GActionFuture<NodesInfoResponse> nodesInfo(NodesInfoRequest request) {
|
||||||
GActionFuture<NodesInfoResponse> future = new GActionFuture<NodesInfoResponse>(internalClient.threadPool(), request);
|
GActionFuture<NodesInfoResponse> future = new GActionFuture<NodesInfoResponse>(internalClient.threadPool(), request)
|
||||||
clusterAdminClient.nodesInfo(request, future)
|
clusterAdminClient.nodesInfo(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ class GClusterAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<NodesStatsResponse> nodesStats(NodesStatsRequest request) {
|
GActionFuture<NodesStatsResponse> nodesStats(NodesStatsRequest request) {
|
||||||
GActionFuture<NodesStatsResponse> future = new GActionFuture<NodesStatsResponse>(internalClient.threadPool(), request);
|
GActionFuture<NodesStatsResponse> future = new GActionFuture<NodesStatsResponse>(internalClient.threadPool(), request)
|
||||||
clusterAdminClient.nodesStats(request, future)
|
clusterAdminClient.nodesStats(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ class GClusterAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<NodesShutdownResponse> nodesShutdown(NodesShutdownRequest request) {
|
GActionFuture<NodesShutdownResponse> nodesShutdown(NodesShutdownRequest request) {
|
||||||
GActionFuture<NodesShutdownResponse> future = new GActionFuture<NodesShutdownResponse>(internalClient.threadPool(), request);
|
GActionFuture<NodesShutdownResponse> future = new GActionFuture<NodesShutdownResponse>(internalClient.threadPool(), request)
|
||||||
clusterAdminClient.nodesShutdown(request, future)
|
clusterAdminClient.nodesShutdown(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ class GClusterAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<NodesRestartResponse> nodesRestart(NodesRestartRequest request) {
|
GActionFuture<NodesRestartResponse> nodesRestart(NodesRestartRequest request) {
|
||||||
GActionFuture<NodesRestartResponse> future = new GActionFuture<NodesRestartResponse>(internalClient.threadPool(), request);
|
GActionFuture<NodesRestartResponse> future = new GActionFuture<NodesRestartResponse>(internalClient.threadPool(), request)
|
||||||
clusterAdminClient.nodesRestart(request, future)
|
clusterAdminClient.nodesRestart(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,14 +124,14 @@ class GIndicesAdminClient {
|
||||||
|
|
||||||
private final GClient gClient
|
private final GClient gClient
|
||||||
|
|
||||||
private final InternalClient internalClient;
|
private final InternalClient internalClient
|
||||||
|
|
||||||
final IndicesAdminClient indicesAdminClient;
|
final IndicesAdminClient indicesAdminClient
|
||||||
|
|
||||||
def GIndicesAdminClient(gClient) {
|
def GIndicesAdminClient(gClient) {
|
||||||
this.gClient = gClient
|
this.gClient = gClient
|
||||||
this.internalClient = gClient.client
|
this.internalClient = gClient.client
|
||||||
this.indicesAdminClient = internalClient.admin().indices();
|
this.indicesAdminClient = internalClient.admin().indices()
|
||||||
}
|
}
|
||||||
|
|
||||||
// STATUS
|
// STATUS
|
||||||
|
@ -149,7 +149,7 @@ class GIndicesAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<IndicesStatusResponse> status(IndicesStatusRequest request) {
|
GActionFuture<IndicesStatusResponse> status(IndicesStatusRequest request) {
|
||||||
GActionFuture<IndicesStatusResponse> future = new GActionFuture<IndicesStatusResponse>(internalClient.threadPool(), request);
|
GActionFuture<IndicesStatusResponse> future = new GActionFuture<IndicesStatusResponse>(internalClient.threadPool(), request)
|
||||||
indicesAdminClient.status(request, future)
|
indicesAdminClient.status(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ class GIndicesAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<CreateIndexResponse> create(CreateIndexRequest request) {
|
GActionFuture<CreateIndexResponse> create(CreateIndexRequest request) {
|
||||||
GActionFuture<CreateIndexResponse> future = new GActionFuture<CreateIndexResponse>(internalClient.threadPool(), request);
|
GActionFuture<CreateIndexResponse> future = new GActionFuture<CreateIndexResponse>(internalClient.threadPool(), request)
|
||||||
indicesAdminClient.create(request, future)
|
indicesAdminClient.create(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ class GIndicesAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<DeleteIndexResponse> delete(DeleteIndexRequest request) {
|
GActionFuture<DeleteIndexResponse> delete(DeleteIndexRequest request) {
|
||||||
GActionFuture<DeleteIndexResponse> future = new GActionFuture<DeleteIndexResponse>(internalClient.threadPool(), request);
|
GActionFuture<DeleteIndexResponse> future = new GActionFuture<DeleteIndexResponse>(internalClient.threadPool(), request)
|
||||||
indicesAdminClient.delete(request, future)
|
indicesAdminClient.delete(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ class GIndicesAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<RefreshResponse> refresh(RefreshRequest request) {
|
GActionFuture<RefreshResponse> refresh(RefreshRequest request) {
|
||||||
GActionFuture<RefreshResponse> future = new GActionFuture<RefreshResponse>(internalClient.threadPool(), request);
|
GActionFuture<RefreshResponse> future = new GActionFuture<RefreshResponse>(internalClient.threadPool(), request)
|
||||||
indicesAdminClient.refresh(request, future)
|
indicesAdminClient.refresh(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ class GIndicesAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<FlushResponse> flush(FlushRequest request) {
|
GActionFuture<FlushResponse> flush(FlushRequest request) {
|
||||||
GActionFuture<FlushResponse> future = new GActionFuture<FlushResponse>(internalClient.threadPool(), request);
|
GActionFuture<FlushResponse> future = new GActionFuture<FlushResponse>(internalClient.threadPool(), request)
|
||||||
indicesAdminClient.flush(request, future)
|
indicesAdminClient.flush(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ class GIndicesAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<OptimizeResponse> optimize(OptimizeRequest request) {
|
GActionFuture<OptimizeResponse> optimize(OptimizeRequest request) {
|
||||||
GActionFuture<OptimizeResponse> future = new GActionFuture<OptimizeResponse>(internalClient.threadPool(), request);
|
GActionFuture<OptimizeResponse> future = new GActionFuture<OptimizeResponse>(internalClient.threadPool(), request)
|
||||||
indicesAdminClient.optimize(request, future)
|
indicesAdminClient.optimize(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ class GIndicesAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<PutMappingResponse> putMapping(PutMappingRequest request) {
|
GActionFuture<PutMappingResponse> putMapping(PutMappingRequest request) {
|
||||||
GActionFuture<PutMappingResponse> future = new GActionFuture<PutMappingResponse>(internalClient.threadPool(), request);
|
GActionFuture<PutMappingResponse> future = new GActionFuture<PutMappingResponse>(internalClient.threadPool(), request)
|
||||||
indicesAdminClient.putMapping(request, future)
|
indicesAdminClient.putMapping(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ class GIndicesAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<GatewaySnapshotResponse> gatewaySnapshot(GatewaySnapshotRequest request) {
|
GActionFuture<GatewaySnapshotResponse> gatewaySnapshot(GatewaySnapshotRequest request) {
|
||||||
GActionFuture<GatewaySnapshotResponse> future = new GActionFuture<GatewaySnapshotResponse>(internalClient.threadPool(), request);
|
GActionFuture<GatewaySnapshotResponse> future = new GActionFuture<GatewaySnapshotResponse>(internalClient.threadPool(), request)
|
||||||
indicesAdminClient.gatewaySnapshot(request, future)
|
indicesAdminClient.gatewaySnapshot(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -341,7 +341,7 @@ class GIndicesAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<IndicesAliasesResponse> aliases(IndicesAliasesRequest request) {
|
GActionFuture<IndicesAliasesResponse> aliases(IndicesAliasesRequest request) {
|
||||||
GActionFuture<IndicesAliasesResponse> future = new GActionFuture<IndicesAliasesResponse>(internalClient.threadPool(), request);
|
GActionFuture<IndicesAliasesResponse> future = new GActionFuture<IndicesAliasesResponse>(internalClient.threadPool(), request)
|
||||||
indicesAdminClient.aliases(request, future)
|
indicesAdminClient.aliases(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ class GIndicesAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<ClearIndicesCacheResponse> clearCache(ClearIndicesCacheRequest request) {
|
GActionFuture<ClearIndicesCacheResponse> clearCache(ClearIndicesCacheRequest request) {
|
||||||
GActionFuture<ClearIndicesCacheResponse> future = new GActionFuture<ClearIndicesCacheResponse>(internalClient.threadPool(), request);
|
GActionFuture<ClearIndicesCacheResponse> future = new GActionFuture<ClearIndicesCacheResponse>(internalClient.threadPool(), request)
|
||||||
indicesAdminClient.clearCache(request, future)
|
indicesAdminClient.clearCache(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -389,7 +389,7 @@ class GIndicesAdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<UpdateSettingsResponse> updateSettings(UpdateSettingsRequest request) {
|
GActionFuture<UpdateSettingsResponse> updateSettings(UpdateSettingsRequest request) {
|
||||||
GActionFuture<UpdateSettingsResponse> future = new GActionFuture<UpdateSettingsResponse>(internalClient.threadPool(), request);
|
GActionFuture<UpdateSettingsResponse> future = new GActionFuture<UpdateSettingsResponse>(internalClient.threadPool(), request)
|
||||||
indicesAdminClient.updateSettings(request, future)
|
indicesAdminClient.updateSettings(request, future)
|
||||||
return future
|
return future
|
||||||
}
|
}
|
||||||
|
@ -397,14 +397,14 @@ class GIndicesAdminClient {
|
||||||
// ANALYZE
|
// ANALYZE
|
||||||
|
|
||||||
AnalyzeRequestBuilder prepareAnalyze(String index, String text) {
|
AnalyzeRequestBuilder prepareAnalyze(String index, String text) {
|
||||||
indicesAdminClient.prepareAnalyze(index, text);
|
indicesAdminClient.prepareAnalyze(index, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<AnalyzeResponse> analyze(Closure c) {
|
GActionFuture<AnalyzeResponse> analyze(Closure c) {
|
||||||
AnalyzeRequest request = new AnalyzeRequest()
|
AnalyzeRequest request = new AnalyzeRequest()
|
||||||
c.setDelegate request
|
c.setDelegate request
|
||||||
c.resolveStrategy = gClient.resolveStrategy;
|
c.resolveStrategy = gClient.resolveStrategy
|
||||||
c.call();
|
c.call()
|
||||||
analyze(request)
|
analyze(request)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,14 +417,14 @@ class GIndicesAdminClient {
|
||||||
// PUT INDEX TEMPLATE
|
// PUT INDEX TEMPLATE
|
||||||
|
|
||||||
PutIndexTemplateRequestBuilder preparePutTemplate(String name) {
|
PutIndexTemplateRequestBuilder preparePutTemplate(String name) {
|
||||||
indicesAdminClient.preparePutTemplate(name);
|
indicesAdminClient.preparePutTemplate(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<PutIndexTemplateResponse> putTemplate(Closure c) {
|
GActionFuture<PutIndexTemplateResponse> putTemplate(Closure c) {
|
||||||
PutIndexTemplateRequest request = new PutIndexTemplateRequest()
|
PutIndexTemplateRequest request = new PutIndexTemplateRequest()
|
||||||
c.setDelegate request
|
c.setDelegate request
|
||||||
c.resolveStrategy = gClient.resolveStrategy;
|
c.resolveStrategy = gClient.resolveStrategy
|
||||||
c.call();
|
c.call()
|
||||||
putTemplate(request)
|
putTemplate(request)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,14 +437,14 @@ class GIndicesAdminClient {
|
||||||
// DELETE INDEX TEMPLATE
|
// DELETE INDEX TEMPLATE
|
||||||
|
|
||||||
DeleteIndexTemplateRequestBuilder prepareDeleteTemplate(String name) {
|
DeleteIndexTemplateRequestBuilder prepareDeleteTemplate(String name) {
|
||||||
indicesAdminClient.prepareDeleteTemplate(name);
|
indicesAdminClient.prepareDeleteTemplate(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
GActionFuture<DeleteIndexTemplateResponse> deleteTemplate(Closure c) {
|
GActionFuture<DeleteIndexTemplateResponse> deleteTemplate(Closure c) {
|
||||||
DeleteIndexTemplateRequest request = new DeleteIndexTemplateRequest()
|
DeleteIndexTemplateRequest request = new DeleteIndexTemplateRequest()
|
||||||
c.setDelegate request
|
c.setDelegate request
|
||||||
c.resolveStrategy = gClient.resolveStrategy;
|
c.resolveStrategy = gClient.resolveStrategy
|
||||||
c.call();
|
c.call()
|
||||||
deleteTemplate(request)
|
deleteTemplate(request)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,9 @@ import org.elasticsearch.common.xcontent.XContentType
|
||||||
*/
|
*/
|
||||||
class GXContentBuilder {
|
class GXContentBuilder {
|
||||||
|
|
||||||
static NODE_ELEMENT = "element"
|
static NODE_ELEMENT = 'element'
|
||||||
|
|
||||||
static int rootResolveStrategy = Closure.OWNER_FIRST; // the default in Closure
|
static int rootResolveStrategy = Closure.OWNER_FIRST // the default in Closure
|
||||||
|
|
||||||
def root
|
def root
|
||||||
|
|
||||||
|
@ -48,26 +48,26 @@ class GXContentBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
String buildAsString(Closure c) {
|
String buildAsString(Closure c) {
|
||||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
|
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON)
|
||||||
def json = build(c)
|
def json = build(c)
|
||||||
builder.map(json);
|
builder.map(json)
|
||||||
return builder.string();
|
return builder.string()
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] buildAsBytes(Closure c) {
|
byte[] buildAsBytes(Closure c) {
|
||||||
return buildAsBytes(c, XContentType.JSON);
|
return buildAsBytes(c, XContentType.JSON)
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] buildAsBytes(Closure c, XContentType contentType) {
|
byte[] buildAsBytes(Closure c, XContentType contentType) {
|
||||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
XContentBuilder builder = XContentFactory.contentBuilder(contentType)
|
||||||
def json = build(c)
|
def json = build(c)
|
||||||
builder.map(json);
|
builder.map(json)
|
||||||
return builder.copiedBytes();
|
return builder.copiedBytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildRoot(Closure c) {
|
private buildRoot(Closure c) {
|
||||||
c.delegate = this
|
c.delegate = this
|
||||||
c.resolveStrategy = rootResolveStrategy;
|
c.resolveStrategy = rootResolveStrategy
|
||||||
root = [:]
|
root = [:]
|
||||||
current = root
|
current = root
|
||||||
def returnValue = c.call()
|
def returnValue = c.call()
|
||||||
|
@ -85,7 +85,6 @@ class GXContentBuilder {
|
||||||
def prev = current
|
def prev = current
|
||||||
def list = []
|
def list = []
|
||||||
try {
|
try {
|
||||||
|
|
||||||
current = list
|
current = list
|
||||||
c.call(list)
|
c.call(list)
|
||||||
}
|
}
|
||||||
|
@ -176,7 +175,6 @@ class GXContentBuilder {
|
||||||
else {
|
else {
|
||||||
return it
|
return it
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
current[propName] = value
|
current[propName] = value
|
||||||
}
|
}
|
||||||
|
@ -188,5 +186,4 @@ class GXContentBuilder {
|
||||||
def getProperty(String propName) {
|
def getProperty(String propName) {
|
||||||
current[propName]
|
current[propName]
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.elasticsearch.groovy.node
|
package org.elasticsearch.groovy.node
|
||||||
|
|
||||||
|
import org.elasticsearch.common.settings.Settings
|
||||||
import org.elasticsearch.groovy.client.GClient
|
import org.elasticsearch.groovy.client.GClient
|
||||||
import org.elasticsearch.node.Node
|
import org.elasticsearch.node.Node
|
||||||
|
|
||||||
|
@ -27,26 +28,26 @@ import org.elasticsearch.node.Node
|
||||||
*/
|
*/
|
||||||
class GNode {
|
class GNode {
|
||||||
|
|
||||||
final Node node;
|
final Node node
|
||||||
|
|
||||||
final GClient client;
|
final GClient client
|
||||||
|
|
||||||
def GNode(Node node) {
|
GNode(Node node) {
|
||||||
this.node = node;
|
this.node = node
|
||||||
this.client = new GClient(node.client())
|
this.client = new GClient(node.client())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The settings that were used to create the node.
|
* The settings that were used to create the node.
|
||||||
*/
|
*/
|
||||||
def getSettings() {
|
Settings getSettings() {
|
||||||
node.settings();
|
node.settings()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the node. If the node is already started, this method is no-op.
|
* Start the node. If the node is already started, this method is no-op.
|
||||||
*/
|
*/
|
||||||
def start() {
|
GNode start() {
|
||||||
node.start()
|
node.start()
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
@ -54,15 +55,15 @@ class GNode {
|
||||||
/**
|
/**
|
||||||
* Stops the node. If the node is already started, this method is no-op.
|
* Stops the node. If the node is already started, this method is no-op.
|
||||||
*/
|
*/
|
||||||
def stop() {
|
GNode stop() {
|
||||||
node.stop()
|
node.stop()
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the node (and {@link #stop} s if its running).
|
* Closes the node (and {@link #stop}s if it's running).
|
||||||
*/
|
*/
|
||||||
def close() {
|
GNode close() {
|
||||||
node.close()
|
node.close()
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,39 +31,39 @@ import org.elasticsearch.node.internal.InternalNode
|
||||||
*
|
*
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class GNodeBuilder {
|
class GNodeBuilder {
|
||||||
|
|
||||||
private final ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder();
|
private final ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder()
|
||||||
|
|
||||||
private boolean loadConfigSettings = true;
|
private boolean loadConfigSettings = true
|
||||||
|
|
||||||
public static GNodeBuilder nodeBuilder() {
|
static GNodeBuilder nodeBuilder() {
|
||||||
new GNodeBuilder()
|
new GNodeBuilder()
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableSettings.Builder getSettings() {
|
ImmutableSettings.Builder getSettings() {
|
||||||
return settingsBuilder;
|
settingsBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
def settings(Settings.Builder settings) {
|
ImmutableSettings.Builder settings(Settings.Builder settings) {
|
||||||
settingsBuilder.put(settings.build())
|
settingsBuilder.put(settings.build())
|
||||||
}
|
}
|
||||||
|
|
||||||
def settings(Settings settings) {
|
ImmutableSettings.Builder settings(Settings settings) {
|
||||||
settingsBuilder.put(settings)
|
settingsBuilder.put(settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
def settings(Closure settings) {
|
ImmutableSettings.Builder settings(Closure settings) {
|
||||||
byte[] settingsBytes = new GXContentBuilder().buildAsBytes(settings)
|
byte[] settingsBytes = new GXContentBuilder().buildAsBytes(settings)
|
||||||
settingsBuilder.put(new JsonSettingsLoader().load(settingsBytes))
|
settingsBuilder.put(new JsonSettingsLoader().load(settingsBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
def build() {
|
GNode build() {
|
||||||
Node node = new InternalNode(settingsBuilder.build(), loadConfigSettings)
|
Node node = new InternalNode(settingsBuilder.build(), loadConfigSettings)
|
||||||
new GNode(node)
|
new GNode(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
def node() {
|
GNode node() {
|
||||||
build().start()
|
build().start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class GXContentBuilderTests extends GroovyTestCase {
|
||||||
def builder = new GXContentBuilder()
|
def builder = new GXContentBuilder()
|
||||||
|
|
||||||
def result = builder.buildAsString {
|
def result = builder.buildAsString {
|
||||||
rootprop = "something"
|
rootprop = 'something'
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals '{"rootprop":"something"}', result.toString()
|
assertEquals '{"rootprop":"something"}', result.toString()
|
||||||
|
@ -39,7 +39,7 @@ class GXContentBuilderTests extends GroovyTestCase {
|
||||||
|
|
||||||
def result = builder.buildAsString {
|
def result = builder.buildAsString {
|
||||||
categories = ['a', 'b', 'c']
|
categories = ['a', 'b', 'c']
|
||||||
rootprop = "something"
|
rootprop = 'something'
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals '{"categories":["a","b","c"],"rootprop":"something"}', result.toString()
|
assertEquals '{"categories":["a","b","c"],"rootprop":"something"}', result.toString()
|
||||||
|
@ -50,7 +50,7 @@ class GXContentBuilderTests extends GroovyTestCase {
|
||||||
|
|
||||||
def result = builder.buildAsString {
|
def result = builder.buildAsString {
|
||||||
categories = ['a', 'b', 'c']
|
categories = ['a', 'b', 'c']
|
||||||
rootprop = "something"
|
rootprop = 'something'
|
||||||
test {
|
test {
|
||||||
subprop = 10
|
subprop = 10
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ class GXContentBuilderTests extends GroovyTestCase {
|
||||||
|
|
||||||
def result = builder.buildAsString {
|
def result = builder.buildAsString {
|
||||||
categories = ['a', 'b', 'c']
|
categories = ['a', 'b', 'c']
|
||||||
rootprop = "something"
|
rootprop = 'something'
|
||||||
test = {
|
test = {
|
||||||
subprop = 10
|
subprop = 10
|
||||||
}
|
}
|
||||||
|
@ -77,9 +77,8 @@ class GXContentBuilderTests extends GroovyTestCase {
|
||||||
def builder = new GXContentBuilder()
|
def builder = new GXContentBuilder()
|
||||||
def result = builder.buildAsString {
|
def result = builder.buildAsString {
|
||||||
categories = ['a', 'b', 'c']
|
categories = ['a', 'b', 'c']
|
||||||
rootprop = "something"
|
rootprop = 'something'
|
||||||
test subprop: 10, three: [1, 2, 3]
|
test subprop: 10, three: [1, 2, 3]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals '{"categories":["a","b","c"],"rootprop":"something","test":{"subprop":10,"three":[1,2,3]}}', result.toString()
|
assertEquals '{"categories":["a","b","c"],"rootprop":"something","test":{"subprop":10,"three":[1,2,3]}}', result.toString()
|
||||||
|
@ -89,7 +88,7 @@ class GXContentBuilderTests extends GroovyTestCase {
|
||||||
void testArrayOfClosures() {
|
void testArrayOfClosures() {
|
||||||
def builder = new GXContentBuilder()
|
def builder = new GXContentBuilder()
|
||||||
def result = builder.buildAsString {
|
def result = builder.buildAsString {
|
||||||
foo = [{ bar = "hello" }]
|
foo = [{ bar = 'hello' }]
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals '{"foo":[{"bar":"hello"}]}', result.toString()
|
assertEquals '{"foo":[{"bar":"hello"}]}', result.toString()
|
||||||
|
@ -125,7 +124,7 @@ class GXContentBuilderTests extends GroovyTestCase {
|
||||||
def results = ['one', 'two', 'three']
|
def results = ['one', 'two', 'three']
|
||||||
|
|
||||||
def result = builder.buildAsString {
|
def result = builder.buildAsString {
|
||||||
books = array {list ->
|
books = array { list ->
|
||||||
for (b in results) {
|
for (b in results) {
|
||||||
list << [title: b]
|
list << [title: b]
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ class BuilderActionsTests {
|
||||||
local = true
|
local = true
|
||||||
}
|
}
|
||||||
gateway {
|
gateway {
|
||||||
type = "none"
|
type = 'none'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,45 +55,43 @@ class BuilderActionsTests {
|
||||||
node.close()
|
node.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSimpleOperations() {
|
void testSimpleOperations() {
|
||||||
def indexR = node.client.prepareIndex("test", "type1", "1").setSource({
|
def indexR = node.client.prepareIndex('test', 'type1', '1').setSource({
|
||||||
test = "value"
|
test = 'value'
|
||||||
complex {
|
complex {
|
||||||
value1 = "value1"
|
value1 = 'value1'
|
||||||
value2 = "value2"
|
value2 = 'value2'
|
||||||
}
|
}
|
||||||
}).gexecute()
|
}).gexecute()
|
||||||
|
|
||||||
assertThat indexR.response.index, equalTo("test")
|
assertThat indexR.response.index, equalTo('test')
|
||||||
assertThat indexR.response.type, equalTo("type1")
|
assertThat indexR.response.type, equalTo('type1')
|
||||||
assertThat indexR.response.id, equalTo("1")
|
assertThat indexR.response.id, equalTo('1')
|
||||||
|
|
||||||
node.client.admin.indices.refresh {}.actionGet()
|
node.client.admin.indices.refresh {}.actionGet()
|
||||||
|
|
||||||
def countR = node.client.prepareCount("test").setQuery({
|
def countR = node.client.prepareCount('test').setQuery({
|
||||||
term(test: "value")
|
term(test: 'value')
|
||||||
}).gexecute();
|
}).gexecute()
|
||||||
|
|
||||||
assertThat countR.response.count, equalTo(1l)
|
assertThat countR.response.count, equalTo(1l)
|
||||||
|
|
||||||
def searchR = node.client.prepareSearch("test").setQuery({
|
def searchR = node.client.prepareSearch('test').setQuery({
|
||||||
term(test: "value")
|
term(test: 'value')
|
||||||
}).gexecute();
|
}).gexecute()
|
||||||
|
|
||||||
assertThat searchR.response.hits.totalHits, equalTo(1l)
|
assertThat searchR.response.hits.totalHits, equalTo(1l)
|
||||||
|
|
||||||
def delete = node.client.prepareDelete("test", "type1", "1").gexecute()
|
def delete = node.client.prepareDelete('test', 'type1', '1').gexecute()
|
||||||
assertThat delete.response.index, equalTo("test")
|
assertThat delete.response.index, equalTo('test')
|
||||||
assertThat delete.response.type, equalTo("type1")
|
assertThat delete.response.type, equalTo('type1')
|
||||||
assertThat delete.response.id, equalTo("1")
|
assertThat delete.response.id, equalTo('1')
|
||||||
|
|
||||||
def refresh = node.client.admin.indices.refresh {}
|
def refresh = node.client.admin.indices.refresh {}
|
||||||
assertThat refresh.response.failedShards, equalTo(0)
|
assertThat refresh.response.failedShards, equalTo(0)
|
||||||
|
|
||||||
def get = node.client.prepareGet("test", "type1", "1").gexecute()
|
def get = node.client.prepareGet('test', 'type1', '1').gexecute()
|
||||||
assertThat get.response.exists, equalTo(false)
|
assertThat get.response.exists, equalTo(false)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -46,7 +46,7 @@ class DifferentApiExecutionTests {
|
||||||
local = true
|
local = true
|
||||||
}
|
}
|
||||||
gateway {
|
gateway {
|
||||||
type = "none"
|
type = 'none'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,93 +61,93 @@ class DifferentApiExecutionTests {
|
||||||
@Test
|
@Test
|
||||||
void verifyDifferentApiExecutions() {
|
void verifyDifferentApiExecutions() {
|
||||||
def response = node.client.index(new IndexRequest(
|
def response = node.client.index(new IndexRequest(
|
||||||
index: "test",
|
index: 'test',
|
||||||
type: "type1",
|
type: 'type1',
|
||||||
id: "1",
|
id: '1',
|
||||||
source: {
|
source: {
|
||||||
test = "value"
|
test = 'value'
|
||||||
complex {
|
complex {
|
||||||
value1 = "value1"
|
value1 = 'value1'
|
||||||
value2 = "value2"
|
value2 = 'value2'
|
||||||
}
|
}
|
||||||
})).response
|
})).response
|
||||||
assertThat response.index, equalTo("test")
|
assertThat response.index, equalTo('test')
|
||||||
assertThat response.type, equalTo("type1")
|
assertThat response.type, equalTo('type1')
|
||||||
assertThat response.id, equalTo("1")
|
assertThat response.id, equalTo('1')
|
||||||
|
|
||||||
def refresh = node.client.admin.indices.refresh {}
|
def refresh = node.client.admin.indices.refresh {}
|
||||||
assertThat 0, equalTo(refresh.response.failedShards)
|
assertThat 0, equalTo(refresh.response.failedShards)
|
||||||
|
|
||||||
def getR = node.client.get {
|
def getR = node.client.get {
|
||||||
index "test"
|
index 'test'
|
||||||
type "type1"
|
type 'type1'
|
||||||
id "1"
|
id '1'
|
||||||
}
|
}
|
||||||
assertThat getR.response.exists, equalTo(true)
|
assertThat getR.response.exists, equalTo(true)
|
||||||
assertThat getR.response.index, equalTo("test")
|
assertThat getR.response.index, equalTo('test')
|
||||||
assertThat getR.response.type, equalTo("type1")
|
assertThat getR.response.type, equalTo('type1')
|
||||||
assertThat getR.response.id, equalTo("1")
|
assertThat getR.response.id, equalTo('1')
|
||||||
assertThat getR.response.sourceAsString(), equalTo('{"test":"value","complex":{"value1":"value1","value2":"value2"}}')
|
assertThat getR.response.sourceAsString(), equalTo('{"test":"value","complex":{"value1":"value1","value2":"value2"}}')
|
||||||
assertThat getR.response.source.test, equalTo("value")
|
assertThat getR.response.source.test, equalTo('value')
|
||||||
assertThat getR.response.source.complex.value1, equalTo("value1")
|
assertThat getR.response.source.complex.value1, equalTo('value1')
|
||||||
|
|
||||||
response = node.client.index({
|
response = node.client.index({
|
||||||
index = "test"
|
index = 'test'
|
||||||
type = "type1"
|
type = 'type1'
|
||||||
id = "1"
|
id = '1'
|
||||||
source = {
|
source = {
|
||||||
test = "value"
|
test = 'value'
|
||||||
complex {
|
complex {
|
||||||
value1 = "value1"
|
value1 = 'value1'
|
||||||
value2 = "value2"
|
value2 = 'value2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).response
|
}).response
|
||||||
assertThat response.index, equalTo("test")
|
assertThat response.index, equalTo('test')
|
||||||
assertThat response.type, equalTo("type1")
|
assertThat response.type, equalTo('type1')
|
||||||
assertThat response.id, equalTo("1")
|
assertThat response.id, equalTo('1')
|
||||||
|
|
||||||
def indexR = node.client.index(indexRequest().with {
|
def indexR = node.client.index(indexRequest().with {
|
||||||
index "test"
|
index 'test'
|
||||||
type "type1"
|
type 'type1'
|
||||||
id "1"
|
id '1'
|
||||||
source {
|
source {
|
||||||
test = "value"
|
test = 'value'
|
||||||
complex {
|
complex {
|
||||||
value1 = "value1"
|
value1 = 'value1'
|
||||||
value2 = "value2"
|
value2 = 'value2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
CountDownLatch latch = new CountDownLatch(1)
|
CountDownLatch latch = new CountDownLatch(1)
|
||||||
indexR.success = {IndexResponse responseX ->
|
indexR.success = { IndexResponse responseX ->
|
||||||
assertThat responseX.index, equalTo("test")
|
assertThat responseX.index, equalTo('test')
|
||||||
assertThat indexR.response.index, equalTo("test")
|
assertThat indexR.response.index, equalTo('test')
|
||||||
assertThat responseX.type, equalTo("type1")
|
assertThat responseX.type, equalTo('type1')
|
||||||
assertThat indexR.response.type, equalTo("type1")
|
assertThat indexR.response.type, equalTo('type1')
|
||||||
assertThat response.id, equalTo("1")
|
assertThat response.id, equalTo('1')
|
||||||
assertThat indexR.response.id, equalTo("1")
|
assertThat indexR.response.id, equalTo('1')
|
||||||
latch.countDown()
|
latch.countDown()
|
||||||
}
|
}
|
||||||
latch.await()
|
latch.await()
|
||||||
|
|
||||||
indexR = node.client.index {
|
indexR = node.client.index {
|
||||||
index "test"
|
index 'test'
|
||||||
type "type1"
|
type 'type1'
|
||||||
id "1"
|
id '1'
|
||||||
source {
|
source {
|
||||||
test = "value"
|
test = 'value'
|
||||||
complex {
|
complex {
|
||||||
value1 = "value1"
|
value1 = 'value1'
|
||||||
value2 = "value2"
|
value2 = 'value2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
latch = new CountDownLatch(1)
|
latch = new CountDownLatch(1)
|
||||||
indexR.listener = {
|
indexR.listener = {
|
||||||
assertThat indexR.response.index, equalTo("test")
|
assertThat indexR.response.index, equalTo('test')
|
||||||
assertThat indexR.response.type, equalTo("type1")
|
assertThat indexR.response.type, equalTo('type1')
|
||||||
assertThat indexR.response.id, equalTo("1")
|
assertThat indexR.response.id, equalTo('1')
|
||||||
latch.countDown()
|
latch.countDown()
|
||||||
}
|
}
|
||||||
latch.await()
|
latch.await()
|
||||||
|
|
|
@ -42,7 +42,7 @@ class SimpleActionsTests {
|
||||||
local = true
|
local = true
|
||||||
}
|
}
|
||||||
gateway {
|
gateway {
|
||||||
type = "none"
|
type = 'none'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,74 +54,73 @@ class SimpleActionsTests {
|
||||||
node.close()
|
node.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSimpleOperations() {
|
void testSimpleOperations() {
|
||||||
def value1 = new org.elasticsearch.groovy.common.xcontent.GXContentBuilder().buildAsString {
|
def value1 = new org.elasticsearch.groovy.common.xcontent.GXContentBuilder().buildAsString {
|
||||||
something = "test"
|
something = 'test'
|
||||||
}
|
}
|
||||||
println value1
|
println value1
|
||||||
|
|
||||||
def indexR = node.client.index {
|
def indexR = node.client.index {
|
||||||
index "test"
|
index 'test'
|
||||||
type "type1"
|
type 'type1'
|
||||||
id "1"
|
id '1'
|
||||||
source {
|
source {
|
||||||
test = "value"
|
test = 'value'
|
||||||
complex {
|
complex {
|
||||||
value1 = "value1"
|
value1 = 'value1'
|
||||||
value2 = "value2"
|
value2 = 'value2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertThat indexR.response.index, equalTo("test")
|
assertThat indexR.response.index, equalTo('test')
|
||||||
assertThat indexR.response.type, equalTo("type1")
|
assertThat indexR.response.type, equalTo('type1')
|
||||||
assertThat indexR.response.id, equalTo("1")
|
assertThat indexR.response.id, equalTo('1')
|
||||||
|
|
||||||
def delete = node.client.delete {
|
def delete = node.client.delete {
|
||||||
index "test"
|
index 'test'
|
||||||
type "type1"
|
type 'type1'
|
||||||
id "1"
|
id '1'
|
||||||
}
|
}
|
||||||
assertThat delete.response.index, equalTo("test")
|
assertThat delete.response.index, equalTo('test')
|
||||||
assertThat delete.response.type, equalTo("type1")
|
assertThat delete.response.type, equalTo('type1')
|
||||||
assertThat delete.response.id, equalTo("1")
|
assertThat delete.response.id, equalTo('1')
|
||||||
|
|
||||||
def refresh = node.client.admin.indices.refresh {}
|
def refresh = node.client.admin.indices.refresh {}
|
||||||
assertThat refresh.response.failedShards, equalTo(0)
|
assertThat refresh.response.failedShards, equalTo(0)
|
||||||
|
|
||||||
def get = node.client.get {
|
def get = node.client.get {
|
||||||
index "test"
|
index 'test'
|
||||||
type "type1"
|
type 'type1'
|
||||||
id "1"
|
id '1'
|
||||||
}
|
}
|
||||||
assertThat get.response.exists, equalTo(false)
|
assertThat get.response.exists, equalTo(false)
|
||||||
|
|
||||||
indexR = node.client.index {
|
indexR = node.client.index {
|
||||||
index "test"
|
index 'test'
|
||||||
type "type1"
|
type 'type1'
|
||||||
id "1"
|
id '1'
|
||||||
source {
|
source {
|
||||||
test = "value"
|
test = 'value'
|
||||||
complex {
|
complex {
|
||||||
value1 = "value1"
|
value1 = 'value1'
|
||||||
value2 = "value2"
|
value2 = 'value2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertThat indexR.response.index, equalTo("test")
|
assertThat indexR.response.index, equalTo('test')
|
||||||
assertThat indexR.response.type, equalTo("type1")
|
assertThat indexR.response.type, equalTo('type1')
|
||||||
assertThat indexR.response.id, equalTo("1")
|
assertThat indexR.response.id, equalTo('1')
|
||||||
|
|
||||||
refresh = node.client.admin.indices.refresh {}
|
refresh = node.client.admin.indices.refresh {}
|
||||||
assertThat refresh.response.failedShards, equalTo(0)
|
assertThat refresh.response.failedShards, equalTo(0)
|
||||||
|
|
||||||
def count = node.client.count {
|
def count = node.client.count {
|
||||||
indices "test"
|
indices 'test'
|
||||||
types "type1"
|
types 'type1'
|
||||||
query {
|
query {
|
||||||
term {
|
term {
|
||||||
test = "value"
|
test = 'value'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,22 +128,22 @@ class SimpleActionsTests {
|
||||||
assertThat count.response.count, equalTo(1l)
|
assertThat count.response.count, equalTo(1l)
|
||||||
|
|
||||||
def search = node.client.search {
|
def search = node.client.search {
|
||||||
indices "test"
|
indices 'test'
|
||||||
types "type1"
|
types 'type1'
|
||||||
source {
|
source {
|
||||||
query {
|
query {
|
||||||
term(test: "value")
|
term(test: 'value')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertThat search.response.failedShards, equalTo(0)
|
assertThat search.response.failedShards, equalTo(0)
|
||||||
assertThat search.response.hits.totalHits, equalTo(1l)
|
assertThat search.response.hits.totalHits, equalTo(1l)
|
||||||
assertThat search.response.hits[0].source.test, equalTo("value")
|
assertThat search.response.hits[0].source.test, equalTo('value')
|
||||||
|
|
||||||
def deleteByQuery = node.client.deleteByQuery {
|
def deleteByQuery = node.client.deleteByQuery {
|
||||||
indices "test"
|
indices 'test'
|
||||||
query {
|
query {
|
||||||
term("test": "value")
|
term(test: 'value')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertThat deleteByQuery.response.indices.test.failedShards, equalTo(0)
|
assertThat deleteByQuery.response.indices.test.failedShards, equalTo(0)
|
||||||
|
@ -153,9 +152,9 @@ class SimpleActionsTests {
|
||||||
assertThat refresh.response.failedShards, equalTo(0)
|
assertThat refresh.response.failedShards, equalTo(0)
|
||||||
|
|
||||||
get = node.client.get {
|
get = node.client.get {
|
||||||
index "test"
|
index 'test'
|
||||||
type "type1"
|
type 'type1'
|
||||||
id "1"
|
id '1'
|
||||||
}
|
}
|
||||||
assertThat get.response.exists, equalTo(false)
|
assertThat get.response.exists, equalTo(false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,13 @@ import static org.elasticsearch.groovy.node.GNodeBuilder.*
|
||||||
class GNodeBuilderTests extends GroovyTestCase {
|
class GNodeBuilderTests extends GroovyTestCase {
|
||||||
|
|
||||||
void testGNodeBuilder() {
|
void testGNodeBuilder() {
|
||||||
GNodeBuilder nodeBuilder = nodeBuilder();
|
GNodeBuilder nodeBuilder = nodeBuilder()
|
||||||
nodeBuilder.settings {
|
nodeBuilder.settings {
|
||||||
node {
|
node {
|
||||||
local = true
|
local = true
|
||||||
}
|
}
|
||||||
cluster {
|
cluster {
|
||||||
name = "test"
|
name = 'test'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GNode node = nodeBuilder.node()
|
GNode node = nodeBuilder.node()
|
||||||
|
|
Loading…
Reference in New Issue