Package org.elasticsearch.client.support
Class AbstractClient
- java.lang.Object
-
- org.elasticsearch.client.support.AbstractClient
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,Client,ElasticsearchClient,Releasable
- Direct Known Subclasses:
FilterClient,NodeClient,TransportClient
public abstract class AbstractClient extends java.lang.Object implements Client
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.logging.log4j.Loggerloggerprotected Settingssettings-
Fields inherited from interface org.elasticsearch.client.Client
CLIENT_TYPE_SETTING_S
-
-
Constructor Summary
Constructors Constructor Description AbstractClient(Settings settings, ThreadPool threadPool)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AdminClientadmin()The admin client that can be used to perform administrative operations.ActionFuture<BulkResponse>bulk(BulkRequest request)Executes a bulk of index / delete operations.voidbulk(BulkRequest request, ActionListener<BulkResponse> listener)Executes a bulk of index / delete operations.ActionFuture<ClearScrollResponse>clearScroll(ClearScrollRequest request)Clears the search contexts associated with specified scroll ids.voidclearScroll(ClearScrollRequest request, ActionListener<ClearScrollResponse> listener)Clears the search contexts associated with specified scroll ids.ActionFuture<DeleteResponse>delete(DeleteRequest request)Deletes a document from the index based on the index, type and id.voiddelete(DeleteRequest request, ActionListener<DeleteResponse> listener)Deletes a document from the index based on the index, type and id.protected abstract <Request extends ActionRequest,Response extends ActionResponse,RequestBuilder extends ActionRequestBuilder<Request,Response,RequestBuilder>>
voiddoExecute(Action<Request,Response,RequestBuilder> action, Request request, ActionListener<Response> listener)<Request extends ActionRequest,Response extends ActionResponse,RequestBuilder extends ActionRequestBuilder<Request,Response,RequestBuilder>>
ActionFuture<Response>execute(Action<Request,Response,RequestBuilder> action, Request request)Executes a generic action, denoted by anAction.<Request extends ActionRequest,Response extends ActionResponse,RequestBuilder extends ActionRequestBuilder<Request,Response,RequestBuilder>>
voidexecute(Action<Request,Response,RequestBuilder> action, Request request, ActionListener<Response> listener)This is the single execution point of *all* clients.ActionFuture<ExplainResponse>explain(ExplainRequest request)Computes a score explanation for the specified request.voidexplain(ExplainRequest request, ActionListener<ExplainResponse> listener)Computes a score explanation for the specified request.ActionFuture<FieldCapabilitiesResponse>fieldCaps(FieldCapabilitiesRequest request)An action that returns the field capabilities from the provided requestvoidfieldCaps(FieldCapabilitiesRequest request, ActionListener<FieldCapabilitiesResponse> listener)An action that returns the field capabilities from the provided requestClientfilterWithHeader(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.ActionFuture<GetResponse>get(GetRequest request)Gets the document that was indexed from an index with a type and id.voidget(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.voidindex(IndexRequest request, ActionListener<IndexResponse> listener)Index a document associated with a given index and type.ActionFuture<MultiGetResponse>multiGet(MultiGetRequest request)Multi get documents.voidmultiGet(MultiGetRequest request, ActionListener<MultiGetResponse> listener)Multi get documents.ActionFuture<MultiSearchResponse>multiSearch(MultiSearchRequest request)Performs multiple search requests.voidmultiSearch(MultiSearchRequest request, ActionListener<MultiSearchResponse> listener)Performs multiple search requests.ActionFuture<MultiTermVectorsResponse>multiTermVectors(MultiTermVectorsRequest request)Multi get term vectors.voidmultiTermVectors(MultiTermVectorsRequest request, ActionListener<MultiTermVectorsResponse> listener)Multi get term vectors.BulkRequestBuilderprepareBulk()Executes a bulk of index / delete operations.BulkRequestBuilderprepareBulk(java.lang.String globalIndex, java.lang.String globalType)Executes a bulk of index / delete operations with default index and/or typeClearScrollRequestBuilderprepareClearScroll()Clears the search contexts associated with specified scroll ids.DeleteRequestBuilderprepareDelete()Deletes a document from the index based on the index, type and id.DeleteRequestBuilderprepareDelete(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.<Request extends ActionRequest,Response extends ActionResponse,RequestBuilder extends ActionRequestBuilder<Request,Response,RequestBuilder>>
RequestBuilderprepareExecute(Action<Request,Response,RequestBuilder> action)Prepares a request builder to execute, specified byAction.ExplainRequestBuilderprepareExplain(java.lang.String index, java.lang.String type, java.lang.String id)Computes a score explanation for the specified request.FieldCapabilitiesRequestBuilderprepareFieldCaps(java.lang.String... indices)Builder for the field capabilities request.GetRequestBuilderprepareGet()Gets the document that was indexed from an index with a type and id.GetRequestBuilderprepareGet(java.lang.String index, java.lang.String type, java.lang.String id)Gets the document that was indexed from an index with a type (optional) and id.IndexRequestBuilderprepareIndex()Index a document associated with a given index and type.IndexRequestBuilderprepareIndex(java.lang.String index, java.lang.String type)Index a document associated with a given index and type.IndexRequestBuilderprepareIndex(java.lang.String index, java.lang.String type, java.lang.String id)Index a document associated with a given index and type.MultiGetRequestBuilderprepareMultiGet()Multi get documents.MultiSearchRequestBuilderprepareMultiSearch()Performs multiple search requests.MultiTermVectorsRequestBuilderprepareMultiTermVectors()Multi get term vectors.SearchRequestBuilderprepareSearch(java.lang.String... indices)Search across one or more indices and one or more types with a query.SearchScrollRequestBuilderprepareSearchScroll(java.lang.String scrollId)A search scroll request to continue searching a previous scrollable search request.TermVectorsRequestBuilderprepareTermVector()Deprecated.TermVectorsRequestBuilderprepareTermVector(java.lang.String index, java.lang.String type, java.lang.String id)Deprecated.TermVectorsRequestBuilderprepareTermVectors()Builder for the term vector request.TermVectorsRequestBuilderprepareTermVectors(java.lang.String index, java.lang.String type, java.lang.String id)Builder for the term vector request.UpdateRequestBuilderprepareUpdate()Updates a document based on a script.UpdateRequestBuilderprepareUpdate(java.lang.String index, java.lang.String type, java.lang.String id)Updates a document based on a script.ActionFuture<SearchResponse>search(SearchRequest request)Search across one or more indices and one or more types with a query.voidsearch(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.voidsearchScroll(SearchScrollRequest request, ActionListener<SearchResponse> listener)A search scroll request to continue searching a previous scrollable search request.Settingssettings()Returns this clients settingsActionFuture<TermVectorsResponse>termVector(TermVectorsRequest request)Deprecated.voidtermVector(TermVectorsRequest request, ActionListener<TermVectorsResponse> listener)Deprecated.ActionFuture<TermVectorsResponse>termVectors(TermVectorsRequest request)An action that returns the term vectors for a specific document.voidtermVectors(TermVectorsRequest request, ActionListener<TermVectorsResponse> listener)An action that returns the term vectors for a specific document.ThreadPoolthreadPool()Returns the threadpool used to execute requests on this clientActionFuture<UpdateResponse>update(UpdateRequest request)Updates a document based on a script.voidupdate(UpdateRequest request, ActionListener<UpdateResponse> listener)Updates a document based on a script.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.client.Client
getRemoteClusterClient
-
Methods inherited from interface org.elasticsearch.common.lease.Releasable
close
-
-
-
-
Field Detail
-
logger
protected final org.apache.logging.log4j.Logger logger
-
settings
protected final Settings settings
-
-
Constructor Detail
-
AbstractClient
public AbstractClient(Settings settings, ThreadPool threadPool)
-
-
Method Detail
-
settings
public final Settings settings()
Description copied from interface:ClientReturns this clients settings
-
threadPool
public final ThreadPool threadPool()
Description copied from interface:ElasticsearchClientReturns the threadpool used to execute requests on this client- Specified by:
threadPoolin interfaceElasticsearchClient
-
admin
public final AdminClient admin()
Description copied from interface:ClientThe admin client that can be used to perform administrative operations.
-
prepareExecute
public final <Request extends ActionRequest,Response extends ActionResponse,RequestBuilder extends ActionRequestBuilder<Request,Response,RequestBuilder>> RequestBuilder prepareExecute(Action<Request,Response,RequestBuilder> action)
Description copied from interface:ElasticsearchClientPrepares a request builder to execute, specified byAction.- Specified by:
prepareExecutein interfaceElasticsearchClient- Type Parameters:
Request- The request type.Response- The response type.RequestBuilder- The request builder.- Parameters:
action- The action type to execute.- Returns:
- The request builder, that can, at a later stage, execute the request.
-
execute
public final <Request extends ActionRequest,Response extends ActionResponse,RequestBuilder extends ActionRequestBuilder<Request,Response,RequestBuilder>> ActionFuture<Response> execute(Action<Request,Response,RequestBuilder> action, Request request)
Description copied from interface:ElasticsearchClientExecutes a generic action, denoted by anAction.- Specified by:
executein interfaceElasticsearchClient- Type Parameters:
Request- The request type.Response- the response type.RequestBuilder- The request builder type.- Parameters:
action- The action type to execute.request- The action request.- Returns:
- A future allowing to get back the response.
-
execute
public final <Request extends ActionRequest,Response extends ActionResponse,RequestBuilder extends ActionRequestBuilder<Request,Response,RequestBuilder>> void execute(Action<Request,Response,RequestBuilder> action, Request request, ActionListener<Response> listener)
This is the single execution point of *all* clients.- Specified by:
executein interfaceElasticsearchClient- Type Parameters:
Request- The request type.Response- The response type.RequestBuilder- The request builder type.- Parameters:
action- The action type to execute.request- The action request.listener- The listener to receive the response back.
-
doExecute
protected abstract <Request extends ActionRequest,Response extends ActionResponse,RequestBuilder extends ActionRequestBuilder<Request,Response,RequestBuilder>> void doExecute(Action<Request,Response,RequestBuilder> action, Request request, ActionListener<Response> listener)
-
index
public ActionFuture<IndexResponse> index(IndexRequest request)
Description copied from interface:ClientIndex a JSON source associated with a given index and type.The id is optional, if it is not provided, one will be generated automatically.
- Specified by:
indexin interfaceClient- Parameters:
request- The index request- Returns:
- The result future
- See Also:
Requests.indexRequest(String)
-
index
public void index(IndexRequest request, ActionListener<IndexResponse> listener)
Description copied from interface:ClientIndex a document associated with a given index and type.The id is optional, if it is not provided, one will be generated automatically.
- Specified by:
indexin interfaceClient- Parameters:
request- The index requestlistener- A listener to be notified with a result- See Also:
Requests.indexRequest(String)
-
prepareIndex
public IndexRequestBuilder prepareIndex()
Description copied from interface:ClientIndex a document associated with a given index and type.The id is optional, if it is not provided, one will be generated automatically.
- Specified by:
prepareIndexin interfaceClient
-
prepareIndex
public IndexRequestBuilder prepareIndex(java.lang.String index, java.lang.String type)
Description copied from interface:ClientIndex a document associated with a given index and type.The id is optional, if it is not provided, one will be generated automatically.
- Specified by:
prepareIndexin interfaceClient- Parameters:
index- The index to index the document totype- The type to index the document to
-
prepareIndex
public IndexRequestBuilder prepareIndex(java.lang.String index, java.lang.String type, @Nullable java.lang.String id)
Description copied from interface:ClientIndex a document associated with a given index and type.The id is optional, if it is not provided, one will be generated automatically.
- Specified by:
prepareIndexin interfaceClient- Parameters:
index- The index to index the document totype- The type to index the document toid- The id of the document
-
update
public ActionFuture<UpdateResponse> update(UpdateRequest request)
Description copied from interface:ClientUpdates a document based on a script.
-
update
public void update(UpdateRequest request, ActionListener<UpdateResponse> listener)
Description copied from interface:ClientUpdates a document based on a script.
-
prepareUpdate
public UpdateRequestBuilder prepareUpdate()
Description copied from interface:ClientUpdates a document based on a script.- Specified by:
prepareUpdatein interfaceClient
-
prepareUpdate
public UpdateRequestBuilder prepareUpdate(java.lang.String index, java.lang.String type, java.lang.String id)
Description copied from interface:ClientUpdates a document based on a script.- Specified by:
prepareUpdatein interfaceClient
-
delete
public ActionFuture<DeleteResponse> delete(DeleteRequest request)
Description copied from interface:ClientDeletes a document from the index based on the index, type and id.- Specified by:
deletein interfaceClient- Parameters:
request- The delete request- Returns:
- The result future
- See Also:
Requests.deleteRequest(String)
-
delete
public void delete(DeleteRequest request, ActionListener<DeleteResponse> listener)
Description copied from interface:ClientDeletes a document from the index based on the index, type and id.- Specified by:
deletein interfaceClient- Parameters:
request- The delete requestlistener- A listener to be notified with a result- See Also:
Requests.deleteRequest(String)
-
prepareDelete
public DeleteRequestBuilder prepareDelete()
Description copied from interface:ClientDeletes a document from the index based on the index, type and id.- Specified by:
prepareDeletein interfaceClient
-
prepareDelete
public DeleteRequestBuilder prepareDelete(java.lang.String index, java.lang.String type, java.lang.String id)
Description copied from interface:ClientDeletes a document from the index based on the index, type and id.- Specified by:
prepareDeletein interfaceClient- Parameters:
index- The index to delete the document fromtype- The type of the document to deleteid- The id of the document to delete
-
bulk
public ActionFuture<BulkResponse> bulk(BulkRequest request)
Description copied from interface:ClientExecutes a bulk of index / delete operations.- Specified by:
bulkin interfaceClient- Parameters:
request- The bulk request- Returns:
- The result future
- See Also:
Requests.bulkRequest()
-
bulk
public void bulk(BulkRequest request, ActionListener<BulkResponse> listener)
Description copied from interface:ClientExecutes a bulk of index / delete operations.- Specified by:
bulkin interfaceClient- Parameters:
request- The bulk requestlistener- A listener to be notified with a result- See Also:
Requests.bulkRequest()
-
prepareBulk
public BulkRequestBuilder prepareBulk()
Description copied from interface:ClientExecutes a bulk of index / delete operations.- Specified by:
prepareBulkin interfaceClient
-
prepareBulk
public BulkRequestBuilder prepareBulk(@Nullable java.lang.String globalIndex, @Nullable java.lang.String globalType)
Description copied from interface:ClientExecutes a bulk of index / delete operations with default index and/or type- Specified by:
prepareBulkin interfaceClient
-
get
public ActionFuture<GetResponse> get(GetRequest request)
Description copied from interface:ClientGets the document that was indexed from an index with a type and id.- Specified by:
getin interfaceClient- Parameters:
request- The get request- Returns:
- The result future
- See Also:
Requests.getRequest(String)
-
get
public void get(GetRequest request, ActionListener<GetResponse> listener)
Description copied from interface:ClientGets the document that was indexed from an index with a type and id.- Specified by:
getin interfaceClient- Parameters:
request- The get requestlistener- A listener to be notified with a result- See Also:
Requests.getRequest(String)
-
prepareGet
public GetRequestBuilder prepareGet()
Description copied from interface:ClientGets the document that was indexed from an index with a type and id.- Specified by:
prepareGetin interfaceClient
-
prepareGet
public GetRequestBuilder prepareGet(java.lang.String index, java.lang.String type, java.lang.String id)
Description copied from interface:ClientGets the document that was indexed from an index with a type (optional) and id.- Specified by:
prepareGetin interfaceClient
-
multiGet
public ActionFuture<MultiGetResponse> multiGet(MultiGetRequest request)
Description copied from interface:ClientMulti get documents.
-
multiGet
public void multiGet(MultiGetRequest request, ActionListener<MultiGetResponse> listener)
Description copied from interface:ClientMulti get documents.
-
prepareMultiGet
public MultiGetRequestBuilder prepareMultiGet()
Description copied from interface:ClientMulti get documents.- Specified by:
prepareMultiGetin interfaceClient
-
search
public ActionFuture<SearchResponse> search(SearchRequest request)
Description copied from interface:ClientSearch across one or more indices and one or more types with a query.- Specified by:
searchin interfaceClient- Parameters:
request- The search request- Returns:
- The result future
- See Also:
Requests.searchRequest(String...)
-
search
public void search(SearchRequest request, ActionListener<SearchResponse> listener)
Description copied from interface:ClientSearch across one or more indices and one or more types with a query.- Specified by:
searchin interfaceClient- Parameters:
request- The search requestlistener- A listener to be notified of the result- See Also:
Requests.searchRequest(String...)
-
prepareSearch
public SearchRequestBuilder prepareSearch(java.lang.String... indices)
Description copied from interface:ClientSearch across one or more indices and one or more types with a query.- Specified by:
prepareSearchin interfaceClient
-
searchScroll
public ActionFuture<SearchResponse> searchScroll(SearchScrollRequest request)
Description copied from interface:ClientA search scroll request to continue searching a previous scrollable search request.- Specified by:
searchScrollin interfaceClient- Parameters:
request- The search scroll request- Returns:
- The result future
- See Also:
Requests.searchScrollRequest(String)
-
searchScroll
public void searchScroll(SearchScrollRequest request, ActionListener<SearchResponse> listener)
Description copied from interface:ClientA search scroll request to continue searching a previous scrollable search request.- Specified by:
searchScrollin interfaceClient- Parameters:
request- The search scroll requestlistener- A listener to be notified of the result- See Also:
Requests.searchScrollRequest(String)
-
prepareSearchScroll
public SearchScrollRequestBuilder prepareSearchScroll(java.lang.String scrollId)
Description copied from interface:ClientA search scroll request to continue searching a previous scrollable search request.- Specified by:
prepareSearchScrollin interfaceClient
-
multiSearch
public ActionFuture<MultiSearchResponse> multiSearch(MultiSearchRequest request)
Description copied from interface:ClientPerforms multiple search requests.- Specified by:
multiSearchin interfaceClient
-
multiSearch
public void multiSearch(MultiSearchRequest request, ActionListener<MultiSearchResponse> listener)
Description copied from interface:ClientPerforms multiple search requests.- Specified by:
multiSearchin interfaceClient
-
prepareMultiSearch
public MultiSearchRequestBuilder prepareMultiSearch()
Description copied from interface:ClientPerforms multiple search requests.- Specified by:
prepareMultiSearchin interfaceClient
-
termVectors
public ActionFuture<TermVectorsResponse> termVectors(TermVectorsRequest request)
Description copied from interface:ClientAn action that returns the term vectors for a specific document.- Specified by:
termVectorsin interfaceClient- Parameters:
request- The term vector request- Returns:
- The response future
-
termVectors
public void termVectors(TermVectorsRequest request, ActionListener<TermVectorsResponse> listener)
Description copied from interface:ClientAn action that returns the term vectors for a specific document.- Specified by:
termVectorsin interfaceClient- Parameters:
request- The term vector request
-
prepareTermVectors
public TermVectorsRequestBuilder prepareTermVectors()
Description copied from interface:ClientBuilder for the term vector request.- Specified by:
prepareTermVectorsin interfaceClient
-
prepareTermVectors
public TermVectorsRequestBuilder prepareTermVectors(java.lang.String index, java.lang.String type, java.lang.String id)
Description copied from interface:ClientBuilder for the term vector request.- Specified by:
prepareTermVectorsin interfaceClient- Parameters:
index- The index to load the document fromtype- The type of the documentid- The id of the document
-
termVector
@Deprecated public ActionFuture<TermVectorsResponse> termVector(TermVectorsRequest request)
Deprecated.Description copied from interface:ClientAn action that returns the term vectors for a specific document.- Specified by:
termVectorin interfaceClient- Parameters:
request- The term vector request- Returns:
- The response future
-
termVector
@Deprecated public void termVector(TermVectorsRequest request, ActionListener<TermVectorsResponse> listener)
Deprecated.Description copied from interface:ClientAn action that returns the term vectors for a specific document.- Specified by:
termVectorin interfaceClient- Parameters:
request- The term vector request
-
prepareTermVector
@Deprecated public TermVectorsRequestBuilder prepareTermVector()
Deprecated.Description copied from interface:ClientBuilder for the term vector request.- Specified by:
prepareTermVectorin interfaceClient
-
prepareTermVector
@Deprecated public TermVectorsRequestBuilder prepareTermVector(java.lang.String index, java.lang.String type, java.lang.String id)
Deprecated.Description copied from interface:ClientBuilder for the term vector request.- Specified by:
prepareTermVectorin interfaceClient- Parameters:
index- The index to load the document fromtype- The type of the documentid- The id of the document
-
multiTermVectors
public ActionFuture<MultiTermVectorsResponse> multiTermVectors(MultiTermVectorsRequest request)
Description copied from interface:ClientMulti get term vectors.- Specified by:
multiTermVectorsin interfaceClient
-
multiTermVectors
public void multiTermVectors(MultiTermVectorsRequest request, ActionListener<MultiTermVectorsResponse> listener)
Description copied from interface:ClientMulti get term vectors.- Specified by:
multiTermVectorsin interfaceClient
-
prepareMultiTermVectors
public MultiTermVectorsRequestBuilder prepareMultiTermVectors()
Description copied from interface:ClientMulti get term vectors.- Specified by:
prepareMultiTermVectorsin interfaceClient
-
prepareExplain
public ExplainRequestBuilder prepareExplain(java.lang.String index, java.lang.String type, java.lang.String id)
Description copied from interface:ClientComputes a score explanation for the specified request.- Specified by:
prepareExplainin interfaceClient- Parameters:
index- The index this explain is targeted fortype- The type this explain is targeted forid- The document identifier this explain is targeted for
-
explain
public ActionFuture<ExplainResponse> explain(ExplainRequest request)
Description copied from interface:ClientComputes a score explanation for the specified request.
-
explain
public void explain(ExplainRequest request, ActionListener<ExplainResponse> listener)
Description copied from interface:ClientComputes a score explanation for the specified request.
-
clearScroll
public void clearScroll(ClearScrollRequest request, ActionListener<ClearScrollResponse> listener)
Description copied from interface:ClientClears the search contexts associated with specified scroll ids.- Specified by:
clearScrollin interfaceClient
-
clearScroll
public ActionFuture<ClearScrollResponse> clearScroll(ClearScrollRequest request)
Description copied from interface:ClientClears the search contexts associated with specified scroll ids.- Specified by:
clearScrollin interfaceClient
-
prepareClearScroll
public ClearScrollRequestBuilder prepareClearScroll()
Description copied from interface:ClientClears the search contexts associated with specified scroll ids.- Specified by:
prepareClearScrollin interfaceClient
-
fieldCaps
public void fieldCaps(FieldCapabilitiesRequest request, ActionListener<FieldCapabilitiesResponse> listener)
Description copied from interface:ClientAn action that returns the field capabilities from the provided request
-
fieldCaps
public ActionFuture<FieldCapabilitiesResponse> fieldCaps(FieldCapabilitiesRequest request)
Description copied from interface:ClientAn action that returns the field capabilities from the provided request
-
prepareFieldCaps
public FieldCapabilitiesRequestBuilder prepareFieldCaps(java.lang.String... indices)
Description copied from interface:ClientBuilder for the field capabilities request.- Specified by:
prepareFieldCapsin interfaceClient
-
filterWithHeader
public Client filterWithHeader(java.util.Map<java.lang.String,java.lang.String> headers)
Description copied from interface:ClientReturns a new lightweight Client that applies all given headers to each of the requests issued from it.- Specified by:
filterWithHeaderin interfaceClient
-
-