org.elasticsearch.client
Class Requests

java.lang.Object
  extended by org.elasticsearch.client.Requests

public class Requests
extends Object

A handy one stop shop for creating requests (make sure to import static this class).


Field Summary
static XContentType CONTENT_TYPE
          The content type used to generate request builders (query / search).
static XContentType INDEX_CONTENT_TYPE
          The default content type to use to generate source documents when indexing.
 
Constructor Summary
Requests()
           
 
Method Summary
static BulkRequest bulkRequest()
          Creats a new bulk request.
static ClearIndicesCacheRequest clearIndicesCacheRequest(String... indices)
          Creates a clean indices cache request.
static CloseIndexRequest closeIndexRequest(String index)
          Creates a close index request.
static ClusterHealthRequest clusterHealthRequest(String... indices)
          Creates a cluster health request.
static ClusterRerouteRequest clusterRerouteRequest()
           
static ClusterStateRequest clusterStateRequest()
          Creates a cluster state request.
static ClusterUpdateSettingsRequest clusterUpdateSettingsRequest()
           
static CountRequest countRequest(String... indices)
          Creates a count request which counts the hits matched against a query.
static CreateIndexRequest createIndexRequest(String index)
          Creates a create index request.
static DeleteByQueryRequest deleteByQueryRequest(String... indices)
          Creates a delete by query request.
static DeleteIndexRequest deleteIndexRequest(String index)
          Creates a delete index request.
static DeleteMappingRequest deleteMappingRequest(String... indices)
          Deletes mapping (and all its data) from one or more indices.
static DeleteRequest deleteRequest(String index)
          Creates a delete request against a specific index.
static FlushRequest flushRequest(String... indices)
          Creates a flush indices request.
static GatewaySnapshotRequest gatewaySnapshotRequest(String... indices)
          Creates a gateway snapshot indices request.
static GetRequest getRequest(String index)
          Creates a get request to get the JSON source from an index based on a type and id.
static IndicesAliasesRequest indexAliasesRequest()
          Creates an index aliases request allowing to add and remove aliases.
static IndexRequest indexRequest()
           
static IndexRequest indexRequest(String index)
          Create an index request against a specific index.
static IndicesExistsRequest indicesExistsRequest(String... indices)
          Creates an indices exists request.
static IndicesSegmentsRequest indicesSegmentsRequest(String... indices)
           
static IndicesStatusRequest indicesStatusRequest(String... indices)
          Creates an indices status request.
static MoreLikeThisRequest moreLikeThisRequest(String index)
          More like this request represents a request to search for documents that are "like" the provided (fetched) document.
static NodesInfoRequest nodesInfoRequest()
          Creates a nodes info request against all the nodes.
static NodesInfoRequest nodesInfoRequest(String... nodesIds)
          Creates a nodes info request against one or more nodes.
static NodesRestartRequest nodesRestartRequest()
          Restarts all nodes in the cluster.
static NodesRestartRequest nodesRestartRequest(String... nodesIds)
          Restarts specific nodes in the cluster.
static NodesShutdownRequest nodesShutdownRequest()
          Shuts down all nodes in the cluster.
static NodesShutdownRequest nodesShutdownRequest(String... nodesIds)
          Shuts down the specified nodes in the cluster.
static NodesStatsRequest nodesStatsRequest(String... nodesIds)
          Creates a nodes stats request against one or more nodes.
static OpenIndexRequest openIndexRequest(String index)
          Creates an open index request.
static OptimizeRequest optimizeRequest(String... indices)
          Creates an optimize request.
static PutMappingRequest putMappingRequest(String... indices)
          Create a create mapping request against one or more indices.
static RefreshRequest refreshRequest(String... indices)
          Creates a refresh indices request.
static SearchRequest searchRequest(String... indices)
          Creates a search request against one or more indices.
static SearchScrollRequest searchScrollRequest(String scrollId)
          Creates a search scroll request allowing to continue searching a previous search request.
static UpdateSettingsRequest updateSettingsRequest(String... indices)
          A request to update indices settings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT_TYPE

public static XContentType CONTENT_TYPE
The content type used to generate request builders (query / search).


INDEX_CONTENT_TYPE

public static XContentType INDEX_CONTENT_TYPE
The default content type to use to generate source documents when indexing.

Constructor Detail

Requests

public Requests()
Method Detail

indexRequest

public static IndexRequest indexRequest()

indexRequest

public static IndexRequest indexRequest(String index)
Create an index request against a specific index. Note the IndexRequest.type(String) must be set as well and optionally the IndexRequest.id(String).

Parameters:
index - The index name to index the request against
Returns:
The index request
See Also:
Client.index(org.elasticsearch.action.index.IndexRequest)

deleteRequest

public static DeleteRequest deleteRequest(String index)
Creates a delete request against a specific index. Note the DeleteRequest.type(String) and DeleteRequest.id(String) must be set.

Parameters:
index - The index name to delete from
Returns:
The delete request
See Also:
Client.delete(org.elasticsearch.action.delete.DeleteRequest)

bulkRequest

public static BulkRequest bulkRequest()
Creats a new bulk request.


deleteByQueryRequest

public static DeleteByQueryRequest deleteByQueryRequest(String... indices)
Creates a delete by query request. Note, the query itself must be set either by setting the JSON source of the query, or by using a QueryBuilder (using QueryBuilders).

Parameters:
indices - The indices the delete by query against. Use null or _all to execute against all indices
Returns:
The delete by query request
See Also:
Client.deleteByQuery(org.elasticsearch.action.deletebyquery.DeleteByQueryRequest)

getRequest

public static GetRequest getRequest(String index)
Creates a get request to get the JSON source from an index based on a type and id. Note, the GetRequest.type(String) and GetRequest.id(String) must be set.

Parameters:
index - The index to get the JSON source from
Returns:
The get request
See Also:
Client.get(org.elasticsearch.action.get.GetRequest)

countRequest

public static CountRequest countRequest(String... indices)
Creates a count request which counts the hits matched against a query. Note, the query itself must be set either using the JSON source of the query, or using a QueryBuilder (using QueryBuilders).

Parameters:
indices - The indices to count matched documents against a query. Use null or _all to execute against all indices
Returns:
The count request
See Also:
Client.count(org.elasticsearch.action.count.CountRequest)

moreLikeThisRequest

public static MoreLikeThisRequest moreLikeThisRequest(String index)
More like this request represents a request to search for documents that are "like" the provided (fetched) document.

Parameters:
index - The index to load the document from
Returns:
The more like this request
See Also:
Client.moreLikeThis(org.elasticsearch.action.mlt.MoreLikeThisRequest)

searchRequest

public static SearchRequest searchRequest(String... indices)
Creates a search request against one or more indices. Note, the search source must be set either using the actual JSON search source, or the SearchSourceBuilder.

Parameters:
indices - The indices to search against. Use null or _all to execute against all indices
Returns:
The search request
See Also:
Client.search(org.elasticsearch.action.search.SearchRequest)

searchScrollRequest

public static SearchScrollRequest searchScrollRequest(String scrollId)
Creates a search scroll request allowing to continue searching a previous search request.

Parameters:
scrollId - The scroll id representing the scrollable search
Returns:
The search scroll request
See Also:
Client.searchScroll(org.elasticsearch.action.search.SearchScrollRequest)

indicesStatusRequest

public static IndicesStatusRequest indicesStatusRequest(String... indices)
Creates an indices status request.

Parameters:
indices - The indices to query status about. Use null or _all to execute against all indices
Returns:
The indices status request
See Also:
IndicesAdminClient.status(org.elasticsearch.action.admin.indices.status.IndicesStatusRequest)

indicesSegmentsRequest

public static IndicesSegmentsRequest indicesSegmentsRequest(String... indices)

indicesExistsRequest

public static IndicesExistsRequest indicesExistsRequest(String... indices)
Creates an indices exists request.

Parameters:
indices - The indices to check if they exists or not.
Returns:
The indices exists request
See Also:
IndicesAdminClient.exists(org.elasticsearch.action.admin.indices.exists.IndicesExistsRequest)

createIndexRequest

public static CreateIndexRequest createIndexRequest(String index)
Creates a create index request.

Parameters:
index - The index to create
Returns:
The index create request
See Also:
IndicesAdminClient.create(org.elasticsearch.action.admin.indices.create.CreateIndexRequest)

deleteIndexRequest

public static DeleteIndexRequest deleteIndexRequest(String index)
Creates a delete index request.

Parameters:
index - The index to delete
Returns:
The delete index request
See Also:
IndicesAdminClient.delete(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)

closeIndexRequest

public static CloseIndexRequest closeIndexRequest(String index)
Creates a close index request.

Parameters:
index - The index to close
Returns:
The delete index request
See Also:
IndicesAdminClient.close(org.elasticsearch.action.admin.indices.close.CloseIndexRequest)

openIndexRequest

public static OpenIndexRequest openIndexRequest(String index)
Creates an open index request.

Parameters:
index - The index to open
Returns:
The delete index request
See Also:
IndicesAdminClient.open(org.elasticsearch.action.admin.indices.open.OpenIndexRequest)

putMappingRequest

public static PutMappingRequest putMappingRequest(String... indices)
Create a create mapping request against one or more indices.

Parameters:
indices - The indices to create mapping. Use null or _all to execute against all indices
Returns:
The create mapping request
See Also:
IndicesAdminClient.putMapping(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest)

deleteMappingRequest

public static DeleteMappingRequest deleteMappingRequest(String... indices)
Deletes mapping (and all its data) from one or more indices.

Parameters:
indices - The indices the mapping will be deleted from. Use null or _all to execute against all indices
Returns:
The create mapping request
See Also:
IndicesAdminClient.deleteMapping(org.elasticsearch.action.admin.indices.mapping.delete.DeleteMappingRequest)

indexAliasesRequest

public static IndicesAliasesRequest indexAliasesRequest()
Creates an index aliases request allowing to add and remove aliases.

Returns:
The index aliases request

refreshRequest

public static RefreshRequest refreshRequest(String... indices)
Creates a refresh indices request.

Parameters:
indices - The indices to refresh. Use null or _all to execute against all indices
Returns:
The refresh request
See Also:
IndicesAdminClient.refresh(org.elasticsearch.action.admin.indices.refresh.RefreshRequest)

flushRequest

public static FlushRequest flushRequest(String... indices)
Creates a flush indices request.

Parameters:
indices - The indices to flush. Use null or _all to execute against all indices
Returns:
The flush request
See Also:
IndicesAdminClient.flush(org.elasticsearch.action.admin.indices.flush.FlushRequest)

optimizeRequest

public static OptimizeRequest optimizeRequest(String... indices)
Creates an optimize request.

Parameters:
indices - The indices to optimize. Use null or _all to execute against all indices
Returns:
The optimize request
See Also:
IndicesAdminClient.optimize(org.elasticsearch.action.admin.indices.optimize.OptimizeRequest)

gatewaySnapshotRequest

public static GatewaySnapshotRequest gatewaySnapshotRequest(String... indices)
Creates a gateway snapshot indices request.

Parameters:
indices - The indices the gateway snapshot will be performed on. Use null or _all to execute against all indices
Returns:
The gateway snapshot request
See Also:
IndicesAdminClient.gatewaySnapshot(org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotRequest)

clearIndicesCacheRequest

public static ClearIndicesCacheRequest clearIndicesCacheRequest(String... indices)
Creates a clean indices cache request.

Parameters:
indices - The indices to clean their caches. Use null or _all to execute against all indices
Returns:
The request

updateSettingsRequest

public static UpdateSettingsRequest updateSettingsRequest(String... indices)
A request to update indices settings.

Parameters:
indices - The indices to update the settings for. Use null or _all to executed against all indices.
Returns:
The request

clusterStateRequest

public static ClusterStateRequest clusterStateRequest()
Creates a cluster state request.

Returns:
The cluster state request.
See Also:
ClusterAdminClient.state(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest)

clusterRerouteRequest

public static ClusterRerouteRequest clusterRerouteRequest()

clusterUpdateSettingsRequest

public static ClusterUpdateSettingsRequest clusterUpdateSettingsRequest()

clusterHealthRequest

public static ClusterHealthRequest clusterHealthRequest(String... indices)
Creates a cluster health request.

Parameters:
indices - The indices to provide additional cluster health information for. Use null or _all to execute against all indices
Returns:
The cluster health request
See Also:
ClusterAdminClient.health(org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest)

nodesInfoRequest

public static NodesInfoRequest nodesInfoRequest()
Creates a nodes info request against all the nodes.

Returns:
The nodes info request
See Also:
ClusterAdminClient.nodesInfo(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest)

nodesInfoRequest

public static NodesInfoRequest nodesInfoRequest(String... nodesIds)
Creates a nodes info request against one or more nodes. Pass null or an empty array for all nodes.

Parameters:
nodesIds - The nodes ids to get the status for
Returns:
The nodes info request
See Also:
ClusterAdminClient.nodesStats(org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest)

nodesStatsRequest

public static NodesStatsRequest nodesStatsRequest(String... nodesIds)
Creates a nodes stats request against one or more nodes. Pass null or an empty array for all nodes.

Parameters:
nodesIds - The nodes ids to get the stats for
Returns:
The nodes info request
See Also:
ClusterAdminClient.nodesStats(org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest)

nodesShutdownRequest

public static NodesShutdownRequest nodesShutdownRequest()
Shuts down all nodes in the cluster.


nodesShutdownRequest

public static NodesShutdownRequest nodesShutdownRequest(String... nodesIds)
Shuts down the specified nodes in the cluster.

Parameters:
nodesIds - The nodes ids to get the status for
Returns:
The nodes info request
See Also:
ClusterAdminClient.nodesShutdown(org.elasticsearch.action.admin.cluster.node.shutdown.NodesShutdownRequest)

nodesRestartRequest

public static NodesRestartRequest nodesRestartRequest()
Restarts all nodes in the cluster.


nodesRestartRequest

public static NodesRestartRequest nodesRestartRequest(String... nodesIds)
Restarts specific nodes in the cluster.

Parameters:
nodesIds - The nodes ids to restart
Returns:
The nodes info request
See Also:
ClusterAdminClient.nodesRestart(org.elasticsearch.action.admin.cluster.node.restart.NodesRestartRequest)


Copyright © 2009-2012. All Rights Reserved.