Interface Client

All Superinterfaces:
java.lang.AutoCloseable, java.io.Closeable, ElasticsearchClient, Releasable
All Known Implementing Classes:
AbstractClient, FilterClient, NodeClient, OriginSettingClient, ParentTaskAssigningClient, RestCancellableNodeClient, TransportClient

public interface Client
extends ElasticsearchClient, Releasable
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
  • Field Details

    • CLIENT_TYPE_SETTING_S

      static final Setting<java.lang.String> CLIENT_TYPE_SETTING_S
  • Method Details

    • admin

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

      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.

    • update

      Updates a document based on a script.
      Parameters:
      request - The update request
      Returns:
      The result future
    • update

      void update​(UpdateRequest request, ActionListener<UpdateResponse> listener)
      Updates a document based on a script.
      Parameters:
      request - The update request
      listener - A listener to be notified with a result
    • prepareUpdate

      UpdateRequestBuilder prepareUpdate()
      Updates a document based on a script.
    • prepareUpdate

      UpdateRequestBuilder prepareUpdate​(java.lang.String index, java.lang.String type, java.lang.String id)
      Updates a document based on a script.
    • 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

      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

      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.
    • prepareBulk

      BulkRequestBuilder prepareBulk​(@Nullable java.lang.String globalIndex, @Nullable java.lang.String globalType)
      Executes a bulk of index / delete operations with default index and/or type
    • get

      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, @Nullable java.lang.String type, java.lang.String id)
      Gets the document that was indexed from an index with a type (optional) and id.
    • multiGet

      Multi get documents.
    • multiGet

      void multiGet​(MultiGetRequest request, ActionListener<MultiGetResponse> listener)
      Multi get documents.
    • prepareMultiGet

      MultiGetRequestBuilder prepareMultiGet()
      Multi get documents.
    • search

      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.
    • multiSearch

      Performs multiple search requests.
    • multiSearch

      void multiSearch​(MultiSearchRequest request, ActionListener<MultiSearchResponse> listener)
      Performs multiple search requests.
    • prepareMultiSearch

      MultiSearchRequestBuilder prepareMultiSearch()
      Performs multiple search requests.
    • termVectors

      An action that returns the term vectors for a specific document.
      Parameters:
      request - The term vector request
      Returns:
      The response future
    • termVectors

      void termVectors​(TermVectorsRequest request, ActionListener<TermVectorsResponse> listener)
      An action that returns the term vectors for a specific document.
      Parameters:
      request - The term vector request
    • prepareTermVectors

      TermVectorsRequestBuilder prepareTermVectors()
      Builder for the term vector request.
    • prepareTermVectors

      TermVectorsRequestBuilder prepareTermVectors​(java.lang.String index, java.lang.String type, java.lang.String id)
      Builder for the term vector request.
      Parameters:
      index - The index to load the document from
      type - The type of the document
      id - The id of the document
    • multiTermVectors

      Multi get term vectors.
    • multiTermVectors

      void multiTermVectors​(MultiTermVectorsRequest request, ActionListener<MultiTermVectorsResponse> listener)
      Multi get term vectors.
    • prepareMultiTermVectors

      MultiTermVectorsRequestBuilder prepareMultiTermVectors()
      Multi get term vectors.
    • prepareExplain

      ExplainRequestBuilder prepareExplain​(java.lang.String index, java.lang.String type, java.lang.String id)
      Computes a score explanation for the specified request.
      Parameters:
      index - The index this explain is targeted for
      type - The type this explain is targeted for
      id - The document identifier this explain is targeted for
    • explain

      Computes a score explanation for the specified request.
      Parameters:
      request - The request encapsulating the query and document identifier to compute a score explanation for
    • explain

      void explain​(ExplainRequest request, ActionListener<ExplainResponse> listener)
      Computes a score explanation for the specified request.
      Parameters:
      request - The request encapsulating the query and document identifier to compute a score explanation for
      listener - A listener to be notified of the result
    • prepareClearScroll

      ClearScrollRequestBuilder prepareClearScroll()
      Clears the search contexts associated with specified scroll ids.
    • clearScroll

      Clears the search contexts associated with specified scroll ids.
    • clearScroll

      void clearScroll​(ClearScrollRequest request, ActionListener<ClearScrollResponse> listener)
      Clears the search contexts associated with specified scroll ids.
    • prepareFieldCaps

      FieldCapabilitiesRequestBuilder prepareFieldCaps​(java.lang.String... indices)
      Builder for the field capabilities request.
    • fieldCaps

      An action that returns the field capabilities from the provided request
    • fieldCaps

      void fieldCaps​(FieldCapabilitiesRequest request, ActionListener<FieldCapabilitiesResponse> listener)
      An action that returns the field capabilities from the provided request
    • settings

      Settings settings()
      Returns this clients settings
    • filterWithHeader

      Client filterWithHeader​(java.util.Map<java.lang.String,​java.lang.String> headers)
      Returns a new lightweight Client that applies all given headers to each of the requests issued from it.
    • getRemoteClusterClient

      default Client getRemoteClusterClient​(java.lang.String clusterAlias)
      Returns a client to a remote cluster with the given cluster alias.
      Throws:
      java.lang.IllegalArgumentException - if the given clusterAlias doesn't exist
      java.lang.UnsupportedOperationException - if this functionality is not available on this client.