org.elasticsearch.client
Class Requests

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

public class Requests
extends java.lang.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).
 
Constructor Summary
Requests()
           
 
Method Summary
static ClearIndicesCacheRequest clearIndicesCache(java.lang.String... indices)
          Creates a clean indices cache request.
static ClusterHealthRequest clusterHealth(java.lang.String... indices)
          Creates a cluster health request.
static ClusterStateRequest clusterState()
          Creates a cluster state request.
static CountRequest countRequest(java.lang.String... indices)
          Creates a count request which counts the hits matched against a query.
static CreateIndexRequest createIndexRequest(java.lang.String index)
          Creates a create index request.
static DeleteByQueryRequest deleteByQueryRequest(java.lang.String... indices)
          Creates a delete by query request.
static DeleteIndexRequest deleteIndexRequest(java.lang.String index)
          Creates a delete index request.
static DeleteRequest deleteRequest(java.lang.String index)
          Creates a delete request against a specific index.
static FlushRequest flushRequest(java.lang.String... indices)
          Creates a flush indices request.
static GatewaySnapshotRequest gatewaySnapshotRequest(java.lang.String... indices)
          Creates a gateway snapshot indices request.
static GetRequest getRequest(java.lang.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(java.lang.String index)
          Create an index request against a specific index.
static IndicesStatusRequest indicesStatus(java.lang.String... indices)
          Creates an indices status request.
static MoreLikeThisRequest moreLikeThisRequest(java.lang.String index)
          More like this request represents a request to search for documents that are "like" the provided (fetched) document.
static NodesInfoRequest nodesInfo()
          Creates a nodes info request against all the nodes.
static NodesInfoRequest nodesInfo(java.lang.String... nodesIds)
          Creates a nodes info request against one or more nodes.
static NodesRestartRequest nodesRestart()
          Restarts all nodes in the cluster.
static NodesRestartRequest nodesRestart(java.lang.String... nodesIds)
          Restarts specific nodes in the cluster.
static NodesShutdownRequest nodesShutdown()
          Shuts down all nodes in the cluster.
static NodesShutdownRequest nodesShutdown(java.lang.String... nodesIds)
          Shuts down the specified nodes in the cluster.
static NodesStatsRequest nodesStats(java.lang.String... nodesIds)
          Creates a nodes stats request against one or more nodes.
static OptimizeRequest optimizeRequest(java.lang.String... indices)
          Creates an optimize request.
static BroadcastPingRequest pingBroadcastRequest(java.lang.String... indices)
           
static ReplicationPingRequest pingReplicationRequest(java.lang.String... indices)
           
static SinglePingRequest pingSingleRequest(java.lang.String index)
           
static PutMappingRequest putMappingRequest(java.lang.String... indices)
          Create a create mapping request against one or more indices.
static RefreshRequest refreshRequest(java.lang.String... indices)
          Creates a refresh indices request.
static SearchRequest searchRequest(java.lang.String... indices)
          Creates a search request against one or more indices.
static SearchScrollRequest searchScrollRequest(java.lang.String scrollId)
          Creates a search scroll request allowing to continue searching a previous search request.
static TermsRequest termsRequest(java.lang.String... indices)
          Terms request represent a request to get terms in one or more indices of specific fields and their document frequencies (in how many document each term exists).
 
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).

Constructor Detail

Requests

public Requests()
Method Detail

indexRequest

public static IndexRequest indexRequest()

indexRequest

public static IndexRequest indexRequest(java.lang.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(java.lang.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)

deleteByQueryRequest

public static DeleteByQueryRequest deleteByQueryRequest(java.lang.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(java.lang.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(java.lang.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 the delete by query against. Use null or _all to execute against all indices
Returns:
The count request
See Also:
Client.count(org.elasticsearch.action.count.CountRequest)

termsRequest

public static TermsRequest termsRequest(java.lang.String... indices)
Terms request represent a request to get terms in one or more indices of specific fields and their document frequencies (in how many document each term exists).

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

moreLikeThisRequest

public static MoreLikeThisRequest moreLikeThisRequest(java.lang.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(java.lang.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 the delete by query 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(java.lang.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)

indicesStatus

public static IndicesStatusRequest indicesStatus(java.lang.String... indices)
Creates an indices status request.

Parameters:
indices - The indices the delete by query against. 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)

createIndexRequest

public static CreateIndexRequest createIndexRequest(java.lang.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(java.lang.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)

putMappingRequest

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

Parameters:
indices - The indices the delete by query against. 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)

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(java.lang.String... indices)
Creates a refresh indices request.

Parameters:
indices - The indices the delete by query against. 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(java.lang.String... indices)
Creates a flush indices request.

Parameters:
indices - The indices the delete by query against. 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(java.lang.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(java.lang.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)

clearIndicesCache

public static ClearIndicesCacheRequest clearIndicesCache(java.lang.String... indices)
Creates a clean indices cache request.

Parameters:
indices - The indices the gateway snapshot will be performed on. Use null or _all to execute against all indices
Returns:
The request

clusterState

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

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

clusterHealth

public static ClusterHealthRequest clusterHealth(java.lang.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)

nodesInfo

public static NodesInfoRequest nodesInfo()
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)

nodesInfo

public static NodesInfoRequest nodesInfo(java.lang.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)

nodesStats

public static NodesStatsRequest nodesStats(java.lang.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)

nodesShutdown

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


nodesShutdown

public static NodesShutdownRequest nodesShutdown(java.lang.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)

nodesRestart

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


nodesRestart

public static NodesRestartRequest nodesRestart(java.lang.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)

pingSingleRequest

public static SinglePingRequest pingSingleRequest(java.lang.String index)

pingBroadcastRequest

public static BroadcastPingRequest pingBroadcastRequest(java.lang.String... indices)

pingReplicationRequest

public static ReplicationPingRequest pingReplicationRequest(java.lang.String... indices)