org.elasticsearch.client
Interface Client

All Known Subinterfaces:
InternalClient
All Known Implementing Classes:
AbstractClient, InternalTransportClient, NodeClient, TransportClient

public interface Client

A client provides a one stop interface for performing actions/operations against the cluster.

All operations performed are asynchronous by nature. Each action/operation has two flavors, the first simply returns an ActionFuture, while the second accepts an ActionListener.

A client can either be retrieved from a Node started, or connected remotely to one or more nodes using TransportClient.

See Also:
Node.client(), TransportClient

Method Summary
 AdminClient admin()
          The admin client that can be used to perform administrative operations.
 ActionFuture<BulkResponse> bulk(BulkRequest request)
          Executes a bulk of index / delete operations.
 void bulk(BulkRequest request, ActionListener<BulkResponse> listener)
          Executes a bulk of index / delete operations.
 void close()
          Closes the client.
 ActionFuture<CountResponse> count(CountRequest request)
          A count of all the documents matching a specific query.
 void count(CountRequest request, ActionListener<CountResponse> listener)
          A count of all the documents matching a specific query.
 ActionFuture<DeleteResponse> delete(DeleteRequest request)
          Deletes a document from the index based on the index, type and id.
 void delete(DeleteRequest request, ActionListener<DeleteResponse> listener)
          Deletes a document from the index based on the index, type and id.
 ActionFuture<DeleteByQueryResponse> deleteByQuery(DeleteByQueryRequest request)
          Deletes all documents from one or more indices based on a query.
 void deleteByQuery(DeleteByQueryRequest request, ActionListener<DeleteByQueryResponse> listener)
          Deletes all documents from one or more indices based on a query.
 ActionFuture<GetResponse> get(GetRequest request)
          Gets the document that was indexed from an index with a type and id.
 void get(GetRequest request, ActionListener<GetResponse> listener)
          Gets the document that was indexed from an index with a type and id.
 ActionFuture<IndexResponse> index(IndexRequest request)
          Index a JSON source associated with a given index and type.
 void index(IndexRequest request, ActionListener<IndexResponse> listener)
          Index a document associated with a given index and type.
 ActionFuture<SearchResponse> moreLikeThis(MoreLikeThisRequest request)
          A more like this action to search for documents that are "like" a specific document.
 void moreLikeThis(MoreLikeThisRequest request, ActionListener<SearchResponse> listener)
          A more like this action to search for documents that are "like" a specific document.
 BulkRequestBuilder prepareBulk()
          Executes a bulk of index / delete operations.
 CountRequestBuilder prepareCount(java.lang.String... indices)
          A count of all the documents matching a specific query.
 DeleteRequestBuilder prepareDelete()
          Deletes a document from the index based on the index, type and id.
 DeleteRequestBuilder prepareDelete(java.lang.String index, java.lang.String type, java.lang.String id)
          Deletes a document from the index based on the index, type and id.
 DeleteByQueryRequestBuilder prepareDeleteByQuery(java.lang.String... indices)
          Deletes all documents from one or more indices based on a query.
 GetRequestBuilder prepareGet()
          Gets the document that was indexed from an index with a type and id.
 GetRequestBuilder prepareGet(java.lang.String index, java.lang.String type, java.lang.String id)
          Gets the document that was indexed from an index with a type and id.
 IndexRequestBuilder prepareIndex()
          Index a document associated with a given index and type.
 IndexRequestBuilder prepareIndex(java.lang.String index, java.lang.String type)
          Index a document associated with a given index and type.
 IndexRequestBuilder prepareIndex(java.lang.String index, java.lang.String type, java.lang.String id)
          Index a document associated with a given index and type.
 SearchRequestBuilder prepareSearch(java.lang.String... indices)
          Search across one or more indices and one or more types with a query.
 SearchScrollRequestBuilder prepareSearchScroll(java.lang.String scrollId)
          A search scroll request to continue searching a previous scrollable search request.
 ActionFuture<SearchResponse> search(SearchRequest request)
          Search across one or more indices and one or more types with a query.
 void search(SearchRequest request, ActionListener<SearchResponse> listener)
          Search across one or more indices and one or more types with a query.
 ActionFuture<SearchResponse> searchScroll(SearchScrollRequest request)
          A search scroll request to continue searching a previous scrollable search request.
 void searchScroll(SearchScrollRequest request, ActionListener<SearchResponse> listener)
          A search scroll request to continue searching a previous scrollable search request.
 

Method Detail

close

void close()
Closes the client.


admin

AdminClient admin()
The admin client that can be used to perform administrative operations.


index

ActionFuture<IndexResponse> index(IndexRequest request)
Index a JSON source associated with a given index and type.

The id is optional, if it is not provided, one will be generated automatically.

Parameters:
request - The index request
Returns:
The result future
See Also:
Requests.indexRequest(String)

index

void index(IndexRequest request,
           ActionListener<IndexResponse> listener)
Index a document associated with a given index and type.

The id is optional, if it is not provided, one will be generated automatically.

Parameters:
request - The index request
listener - A listener to be notified with a result
See Also:
Requests.indexRequest(String)

prepareIndex

IndexRequestBuilder prepareIndex()
Index a document associated with a given index and type.

The id is optional, if it is not provided, one will be generated automatically.


prepareIndex

IndexRequestBuilder prepareIndex(java.lang.String index,
                                 java.lang.String type)
Index a document associated with a given index and type.

The id is optional, if it is not provided, one will be generated automatically.

Parameters:
index - The index to index the document to
type - The type to index the document to

prepareIndex

IndexRequestBuilder prepareIndex(java.lang.String index,
                                 java.lang.String type,
                                 @Nullable
                                 java.lang.String id)
Index a document associated with a given index and type.

The id is optional, if it is not provided, one will be generated automatically.

Parameters:
index - The index to index the document to
type - The type to index the document to
id - The id of the document

delete

ActionFuture<DeleteResponse> delete(DeleteRequest request)
Deletes a document from the index based on the index, type and id.

Parameters:
request - The delete request
Returns:
The result future
See Also:
Requests.deleteRequest(String)

delete

void delete(DeleteRequest request,
            ActionListener<DeleteResponse> listener)
Deletes a document from the index based on the index, type and id.

Parameters:
request - The delete request
listener - A listener to be notified with a result
See Also:
Requests.deleteRequest(String)

prepareDelete

DeleteRequestBuilder prepareDelete()
Deletes a document from the index based on the index, type and id.


prepareDelete

DeleteRequestBuilder prepareDelete(java.lang.String index,
                                   java.lang.String type,
                                   java.lang.String id)
Deletes a document from the index based on the index, type and id.

Parameters:
index - The index to delete the document from
type - The type of the document to delete
id - The id of the document to delete

bulk

ActionFuture<BulkResponse> bulk(BulkRequest request)
Executes a bulk of index / delete operations.

Parameters:
request - The bulk request
Returns:
The result future
See Also:
Requests.bulkRequest()

bulk

void bulk(BulkRequest request,
          ActionListener<BulkResponse> listener)
Executes a bulk of index / delete operations.

Parameters:
request - The bulk request
listener - A listener to be notified with a result
See Also:
Requests.bulkRequest()

prepareBulk

BulkRequestBuilder prepareBulk()
Executes a bulk of index / delete operations.


deleteByQuery

ActionFuture<DeleteByQueryResponse> deleteByQuery(DeleteByQueryRequest request)
Deletes all documents from one or more indices based on a query.

Parameters:
request - The delete by query request
Returns:
The result future
See Also:
Requests.deleteByQueryRequest(String...)

deleteByQuery

void deleteByQuery(DeleteByQueryRequest request,
                   ActionListener<DeleteByQueryResponse> listener)
Deletes all documents from one or more indices based on a query.

Parameters:
request - The delete by query request
listener - A listener to be notified with a result
See Also:
Requests.deleteByQueryRequest(String...)

prepareDeleteByQuery

DeleteByQueryRequestBuilder prepareDeleteByQuery(java.lang.String... indices)
Deletes all documents from one or more indices based on a query.


get

ActionFuture<GetResponse> get(GetRequest request)
Gets the document that was indexed from an index with a type and id.

Parameters:
request - The get request
Returns:
The result future
See Also:
Requests.getRequest(String)

get

void get(GetRequest request,
         ActionListener<GetResponse> listener)
Gets the document that was indexed from an index with a type and id.

Parameters:
request - The get request
listener - A listener to be notified with a result
See Also:
Requests.getRequest(String)

prepareGet

GetRequestBuilder prepareGet()
Gets the document that was indexed from an index with a type and id.


prepareGet

GetRequestBuilder prepareGet(java.lang.String index,
                             java.lang.String type,
                             java.lang.String id)
Gets the document that was indexed from an index with a type and id.


count

ActionFuture<CountResponse> count(CountRequest request)
A count of all the documents matching a specific query.

Parameters:
request - The count request
Returns:
The result future
See Also:
Requests.countRequest(String...)

count

void count(CountRequest request,
           ActionListener<CountResponse> listener)
A count of all the documents matching a specific query.

Parameters:
request - The count request
listener - A listener to be notified of the result
See Also:
Requests.countRequest(String...)

prepareCount

CountRequestBuilder prepareCount(java.lang.String... indices)
A count of all the documents matching a specific query.


search

ActionFuture<SearchResponse> search(SearchRequest request)
Search across one or more indices and one or more types with a query.

Parameters:
request - The search request
Returns:
The result future
See Also:
Requests.searchRequest(String...)

search

void search(SearchRequest request,
            ActionListener<SearchResponse> listener)
Search across one or more indices and one or more types with a query.

Parameters:
request - The search request
listener - A listener to be notified of the result
See Also:
Requests.searchRequest(String...)

prepareSearch

SearchRequestBuilder prepareSearch(java.lang.String... indices)
Search across one or more indices and one or more types with a query.


searchScroll

ActionFuture<SearchResponse> searchScroll(SearchScrollRequest request)
A search scroll request to continue searching a previous scrollable search request.

Parameters:
request - The search scroll request
Returns:
The result future
See Also:
Requests.searchScrollRequest(String)

searchScroll

void searchScroll(SearchScrollRequest request,
                  ActionListener<SearchResponse> listener)
A search scroll request to continue searching a previous scrollable search request.

Parameters:
request - The search scroll request
listener - A listener to be notified of the result
See Also:
Requests.searchScrollRequest(String)

prepareSearchScroll

SearchScrollRequestBuilder prepareSearchScroll(java.lang.String scrollId)
A search scroll request to continue searching a previous scrollable search request.


moreLikeThis

ActionFuture<SearchResponse> moreLikeThis(MoreLikeThisRequest request)
A more like this action to search for documents that are "like" a specific document.

Parameters:
request - The more like this request
Returns:
The response future

moreLikeThis

void moreLikeThis(MoreLikeThisRequest request,
                  ActionListener<SearchResponse> listener)
A more like this action to search for documents that are "like" a specific document.

Parameters:
request - The more like this request
listener - A listener to be notified of the result