Package org.elasticsearch.client
Class RestHighLevelClient
- java.lang.Object
-
- org.elasticsearch.client.RestHighLevelClient
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class RestHighLevelClient extends java.lang.Object implements java.io.Closeable
High level REST client that wraps an instance of the low levelRestClient
and allows to build requests and read responses. TheRestClient
instance is internally built based on the providedRestClientBuilder
and it gets closed automatically when closing theRestHighLevelClient
instance that wraps it. In case an already existing instance of a low-level REST client needs to be provided, this class can be subclassed and theRestHighLevelClient(RestClient, CheckedConsumer, List)
constructor can be used. This class can also be sub-classed to expose additional client methods that make use of endpoints added to Elasticsearch through plugins, or to add support for custom response sections, again added to Elasticsearch through plugins.
-
-
Constructor Summary
Constructors Modifier Constructor Description RestHighLevelClient(RestClientBuilder restClientBuilder)
Creates aRestHighLevelClient
given the low levelRestClientBuilder
that allows to build theRestClient
to be used to perform requests.protected
RestHighLevelClient(RestClientBuilder restClientBuilder, java.util.List<NamedXContentRegistry.Entry> namedXContentEntries)
Creates aRestHighLevelClient
given the low levelRestClientBuilder
that allows to build theRestClient
to be used to perform requests and parsers for custom response sections added to Elasticsearch through plugins.protected
RestHighLevelClient(RestClient restClient, CheckedConsumer<RestClient,java.io.IOException> doClose, java.util.List<NamedXContentRegistry.Entry> namedXContentEntries)
Creates aRestHighLevelClient
given the low levelRestClient
that it should use to perform requests and a list of entries that allow to parse custom response sections added to Elasticsearch through plugins.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BulkResponse
bulk(BulkRequest bulkRequest, org.apache.http.Header... headers)
Deprecated.BulkResponse
bulk(BulkRequest bulkRequest, RequestOptions options)
Executes a bulk request using the Bulk API.void
bulkAsync(BulkRequest bulkRequest, ActionListener<BulkResponse> listener, org.apache.http.Header... headers)
Deprecated.void
bulkAsync(BulkRequest bulkRequest, RequestOptions options, ActionListener<BulkResponse> listener)
Asynchronously executes a bulk request using the Bulk API.ClearScrollResponse
clearScroll(ClearScrollRequest clearScrollRequest, org.apache.http.Header... headers)
Deprecated.ClearScrollResponse
clearScroll(ClearScrollRequest clearScrollRequest, RequestOptions options)
Clears one or more scroll ids using the Clear Scroll API.void
clearScrollAsync(ClearScrollRequest clearScrollRequest, ActionListener<ClearScrollResponse> listener, org.apache.http.Header... headers)
Deprecated.void
clearScrollAsync(ClearScrollRequest clearScrollRequest, RequestOptions options, ActionListener<ClearScrollResponse> listener)
Asynchronously clears one or more scroll ids using the Clear Scroll API.void
close()
ClusterClient
cluster()
Provides aClusterClient
which can be used to access the Cluster API.DeleteResponse
delete(DeleteRequest deleteRequest, org.apache.http.Header... headers)
Deprecated.DeleteResponse
delete(DeleteRequest deleteRequest, RequestOptions options)
Deletes a document by id using the Delete API.void
deleteAsync(DeleteRequest deleteRequest, ActionListener<DeleteResponse> listener, org.apache.http.Header... headers)
Deprecated.void
deleteAsync(DeleteRequest deleteRequest, RequestOptions options, ActionListener<DeleteResponse> listener)
Asynchronously deletes a document by id using the Delete API.DeleteStoredScriptResponse
deleteScript(DeleteStoredScriptRequest request, RequestOptions options)
Delete stored script by id.void
deleteScriptAsync(DeleteStoredScriptRequest request, RequestOptions options, ActionListener<DeleteStoredScriptResponse> listener)
Asynchronously delete stored script by id.boolean
exists(GetRequest getRequest, org.apache.http.Header... headers)
Deprecated.boolean
exists(GetRequest getRequest, RequestOptions options)
Checks for the existence of a document.void
existsAsync(GetRequest getRequest, ActionListener<java.lang.Boolean> listener, org.apache.http.Header... headers)
Deprecated.void
existsAsync(GetRequest getRequest, RequestOptions options, ActionListener<java.lang.Boolean> listener)
Asynchronously checks for the existence of a document.ExplainResponse
explain(ExplainRequest explainRequest, RequestOptions options)
Executes a request using the Explain API.void
explainAsync(ExplainRequest explainRequest, RequestOptions options, ActionListener<ExplainResponse> listener)
Asynchronously executes a request using the Explain API.FieldCapabilitiesResponse
fieldCaps(FieldCapabilitiesRequest fieldCapabilitiesRequest, RequestOptions options)
Executes a request using the Field Capabilities API.void
fieldCapsAsync(FieldCapabilitiesRequest fieldCapabilitiesRequest, RequestOptions options, ActionListener<FieldCapabilitiesResponse> listener)
Asynchronously executes a request using the Field Capabilities API.GetResponse
get(GetRequest getRequest, org.apache.http.Header... headers)
Deprecated.GetResponse
get(GetRequest getRequest, RequestOptions options)
Retrieves a document by id using the Get API.void
getAsync(GetRequest getRequest, ActionListener<GetResponse> listener, org.apache.http.Header... headers)
Deprecated.void
getAsync(GetRequest getRequest, RequestOptions options, ActionListener<GetResponse> listener)
Asynchronously retrieves a document by id using the Get API.RestClient
getLowLevelClient()
Returns the low-level client that the current high-level client instance is using to perform requestsGetStoredScriptResponse
getScript(GetStoredScriptRequest request, RequestOptions options)
Get stored script by id.void
getScriptAsync(GetStoredScriptRequest request, RequestOptions options, ActionListener<GetStoredScriptResponse> listener)
Asynchronously get stored script by id.IndexResponse
index(IndexRequest indexRequest, org.apache.http.Header... headers)
Deprecated.IndexResponse
index(IndexRequest indexRequest, RequestOptions options)
Index a document using the Index API.void
indexAsync(IndexRequest indexRequest, ActionListener<IndexResponse> listener, org.apache.http.Header... headers)
Deprecated.void
indexAsync(IndexRequest indexRequest, RequestOptions options, ActionListener<IndexResponse> listener)
Asynchronously index a document using the Index API.IndicesClient
indices()
Provides anIndicesClient
which can be used to access the Indices API.MainResponse
info(org.apache.http.Header... headers)
Deprecated.Preferinfo(RequestOptions)
MainResponse
info(RequestOptions options)
Get the cluster info otherwise provided when sending an HTTP request to '/'IngestClient
ingest()
Provides aIngestClient
which can be used to access the Ingest API.MultiGetResponse
mget(MultiGetRequest multiGetRequest, RequestOptions options)
Retrieves multiple documents by id using the Multi Get API.void
mgetAsync(MultiGetRequest multiGetRequest, RequestOptions options, ActionListener<MultiGetResponse> listener)
Asynchronously retrieves multiple documents by id using the Multi Get API.MultiSearchResponse
msearch(MultiSearchRequest multiSearchRequest, RequestOptions options)
Executes a multi search using the msearch API.void
msearchAsync(MultiSearchRequest searchRequest, RequestOptions options, ActionListener<MultiSearchResponse> listener)
Asynchronously executes a multi search using the msearch API.MultiSearchTemplateResponse
msearchTemplate(MultiSearchTemplateRequest multiSearchTemplateRequest, RequestOptions options)
Executes a request using the Multi Search Template API.void
msearchTemplateAsync(MultiSearchTemplateRequest multiSearchTemplateRequest, RequestOptions options, ActionListener<MultiSearchTemplateResponse> listener)
Asynchronously executes a request using the Multi Search Template API See Multi Search Template API on elastic.co.MultiGetResponse
multiGet(MultiGetRequest multiGetRequest, org.apache.http.Header... headers)
Deprecated.MultiGetResponse
multiGet(MultiGetRequest multiGetRequest, RequestOptions options)
Deprecated.usemget(MultiGetRequest, RequestOptions)
insteadvoid
multiGetAsync(MultiGetRequest multiGetRequest, ActionListener<MultiGetResponse> listener, org.apache.http.Header... headers)
Deprecated.void
multiGetAsync(MultiGetRequest multiGetRequest, RequestOptions options, ActionListener<MultiGetResponse> listener)
Deprecated.MultiSearchResponse
multiSearch(MultiSearchRequest multiSearchRequest, org.apache.http.Header... headers)
Deprecated.MultiSearchResponse
multiSearch(MultiSearchRequest multiSearchRequest, RequestOptions options)
Deprecated.usemsearch(MultiSearchRequest, RequestOptions)
insteadvoid
multiSearchAsync(MultiSearchRequest searchRequest, ActionListener<MultiSearchResponse> listener, org.apache.http.Header... headers)
Deprecated.void
multiSearchAsync(MultiSearchRequest searchRequest, RequestOptions options, ActionListener<MultiSearchResponse> listener)
Deprecated.protected <Resp> Resp
parseEntity(org.apache.http.HttpEntity entity, CheckedFunction<XContentParser,Resp,java.io.IOException> entityParser)
protected ElasticsearchStatusException
parseResponseException(ResponseException responseException)
Converts aResponseException
obtained from the low level REST client into anElasticsearchException
.protected <Req extends ActionRequest,Resp>
RespperformRequest(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, RequestOptions options, CheckedFunction<Response,Resp,java.io.IOException> responseConverter, java.util.Set<java.lang.Integer> ignores)
protected <Req extends ActionRequest,Resp>
RespperformRequest(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, CheckedFunction<Response,Resp,java.io.IOException> responseConverter, java.util.Set<java.lang.Integer> ignores, org.apache.http.Header... headers)
Deprecated.protected <Req extends ActionRequest,Resp>
RespperformRequestAndParseEntity(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, RequestOptions options, CheckedFunction<XContentParser,Resp,java.io.IOException> entityParser, java.util.Set<java.lang.Integer> ignores)
protected <Req extends ActionRequest,Resp>
RespperformRequestAndParseEntity(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, CheckedFunction<XContentParser,Resp,java.io.IOException> entityParser, java.util.Set<java.lang.Integer> ignores, org.apache.http.Header... headers)
Deprecated.protected <Req extends ActionRequest,Resp>
voidperformRequestAsync(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, RequestOptions options, CheckedFunction<Response,Resp,java.io.IOException> responseConverter, ActionListener<Resp> listener, java.util.Set<java.lang.Integer> ignores)
protected <Req extends ActionRequest,Resp>
voidperformRequestAsync(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, CheckedFunction<Response,Resp,java.io.IOException> responseConverter, ActionListener<Resp> listener, java.util.Set<java.lang.Integer> ignores, org.apache.http.Header... headers)
Deprecated.protected <Req extends ActionRequest,Resp>
voidperformRequestAsyncAndParseEntity(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, RequestOptions options, CheckedFunction<XContentParser,Resp,java.io.IOException> entityParser, ActionListener<Resp> listener, java.util.Set<java.lang.Integer> ignores)
protected <Req extends ActionRequest,Resp>
voidperformRequestAsyncAndParseEntity(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, CheckedFunction<XContentParser,Resp,java.io.IOException> entityParser, ActionListener<Resp> listener, java.util.Set<java.lang.Integer> ignores, org.apache.http.Header... headers)
Deprecated.boolean
ping(org.apache.http.Header... headers)
Deprecated.Preferping(RequestOptions)
boolean
ping(RequestOptions options)
Pings the remote Elasticsearch cluster and returns true if the ping succeeded, false otherwiseRankEvalResponse
rankEval(RankEvalRequest rankEvalRequest, org.apache.http.Header... headers)
Deprecated.RankEvalResponse
rankEval(RankEvalRequest rankEvalRequest, RequestOptions options)
Executes a request using the Ranking Evaluation API.void
rankEvalAsync(RankEvalRequest rankEvalRequest, ActionListener<RankEvalResponse> listener, org.apache.http.Header... headers)
Deprecated.void
rankEvalAsync(RankEvalRequest rankEvalRequest, RequestOptions options, ActionListener<RankEvalResponse> listener)
Asynchronously executes a request using the Ranking Evaluation API.SearchResponse
scroll(SearchScrollRequest searchScrollRequest, RequestOptions options)
Executes a search using the Search Scroll API.void
scrollAsync(SearchScrollRequest searchScrollRequest, RequestOptions options, ActionListener<SearchResponse> listener)
Asynchronously executes a search using the Search Scroll API.SearchResponse
search(SearchRequest searchRequest, org.apache.http.Header... headers)
Deprecated.SearchResponse
search(SearchRequest searchRequest, RequestOptions options)
Executes a search request using the Search API.void
searchAsync(SearchRequest searchRequest, ActionListener<SearchResponse> listener, org.apache.http.Header... headers)
Deprecated.void
searchAsync(SearchRequest searchRequest, RequestOptions options, ActionListener<SearchResponse> listener)
Asynchronously executes a search using the Search API.SearchResponse
searchScroll(SearchScrollRequest searchScrollRequest, org.apache.http.Header... headers)
Deprecated.SearchResponse
searchScroll(SearchScrollRequest searchScrollRequest, RequestOptions options)
Deprecated.usescroll(SearchScrollRequest, RequestOptions)
insteadvoid
searchScrollAsync(SearchScrollRequest searchScrollRequest, ActionListener<SearchResponse> listener, org.apache.http.Header... headers)
Deprecated.void
searchScrollAsync(SearchScrollRequest searchScrollRequest, RequestOptions options, ActionListener<SearchResponse> listener)
Deprecated.SearchTemplateResponse
searchTemplate(SearchTemplateRequest searchTemplateRequest, RequestOptions options)
Executes a request using the Search Template API.void
searchTemplateAsync(SearchTemplateRequest searchTemplateRequest, RequestOptions options, ActionListener<SearchTemplateResponse> listener)
Asynchronously executes a request using the Search Template API.SnapshotClient
snapshot()
Provides aSnapshotClient
which can be used to access the Snapshot API.TasksClient
tasks()
Provides aTasksClient
which can be used to access the Tasks API.UpdateResponse
update(UpdateRequest updateRequest, org.apache.http.Header... headers)
Deprecated.UpdateResponse
update(UpdateRequest updateRequest, RequestOptions options)
Updates a document using the Update API.void
updateAsync(UpdateRequest updateRequest, ActionListener<UpdateResponse> listener, org.apache.http.Header... headers)
Deprecated.void
updateAsync(UpdateRequest updateRequest, RequestOptions options, ActionListener<UpdateResponse> listener)
Asynchronously updates a document using the Update API.WatcherClient
watcher()
Provides methods for accessing the Elastic Licensed Watcher APIs that are shipped with the default distribution of Elasticsearch.XPackClient
xpack()
Provides methods for accessing the Elastic Licensed X-Pack Info and Usage APIs that are shipped with the default distribution of Elasticsearch.
-
-
-
Constructor Detail
-
RestHighLevelClient
public RestHighLevelClient(RestClientBuilder restClientBuilder)
Creates aRestHighLevelClient
given the low levelRestClientBuilder
that allows to build theRestClient
to be used to perform requests.
-
RestHighLevelClient
protected RestHighLevelClient(RestClientBuilder restClientBuilder, java.util.List<NamedXContentRegistry.Entry> namedXContentEntries)
Creates aRestHighLevelClient
given the low levelRestClientBuilder
that allows to build theRestClient
to be used to perform requests and parsers for custom response sections added to Elasticsearch through plugins.
-
RestHighLevelClient
protected RestHighLevelClient(RestClient restClient, CheckedConsumer<RestClient,java.io.IOException> doClose, java.util.List<NamedXContentRegistry.Entry> namedXContentEntries)
Creates aRestHighLevelClient
given the low levelRestClient
that it should use to perform requests and a list of entries that allow to parse custom response sections added to Elasticsearch through plugins. This constructor can be called by subclasses in case an externally created low-level REST client needs to be provided. The consumer argument allows to control what needs to be done when theclose()
method is called. Also subclasses can provide parsers for custom response sections added to Elasticsearch through plugins.
-
-
Method Detail
-
getLowLevelClient
public final RestClient getLowLevelClient()
Returns the low-level client that the current high-level client instance is using to perform requests
-
close
public final void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
indices
public final IndicesClient indices()
Provides anIndicesClient
which can be used to access the Indices API. See Indices API on elastic.co
-
cluster
public final ClusterClient cluster()
Provides aClusterClient
which can be used to access the Cluster API. See Cluster API on elastic.co
-
ingest
public final IngestClient ingest()
Provides aIngestClient
which can be used to access the Ingest API. See Ingest API on elastic.co
-
snapshot
public final SnapshotClient snapshot()
Provides aSnapshotClient
which can be used to access the Snapshot API. See Snapshot API on elastic.co
-
tasks
public final TasksClient tasks()
Provides aTasksClient
which can be used to access the Tasks API. See Task Management API on elastic.co
-
xpack
public final XPackClient xpack()
Provides methods for accessing the Elastic Licensed X-Pack Info and Usage APIs that are shipped with the default distribution of Elasticsearch. All of these APIs will 404 if run against the OSS distribution of Elasticsearch.See the Info APIs on elastic.co for more information.
-
watcher
public WatcherClient watcher()
Provides methods for accessing the Elastic Licensed Watcher APIs that are shipped with the default distribution of Elasticsearch. All of these APIs will 404 if run against the OSS distribution of Elasticsearch.See the Watcher APIs on elastic.co for more information.
-
bulk
public final BulkResponse bulk(BulkRequest bulkRequest, RequestOptions options) throws java.io.IOException
Executes a bulk request using the Bulk API. See Bulk API on elastic.co- Parameters:
bulkRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
bulk
@Deprecated public final BulkResponse bulk(BulkRequest bulkRequest, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Executes a bulk request using the Bulk API. See Bulk API on elastic.co- Throws:
java.io.IOException
-
bulkAsync
public final void bulkAsync(BulkRequest bulkRequest, RequestOptions options, ActionListener<BulkResponse> listener)
Asynchronously executes a bulk request using the Bulk API. See Bulk API on elastic.co- Parameters:
bulkRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
bulkAsync
@Deprecated public final void bulkAsync(BulkRequest bulkRequest, ActionListener<BulkResponse> listener, org.apache.http.Header... headers)
Deprecated.Asynchronously executes a bulk request using the Bulk API. See Bulk API on elastic.co
-
ping
public final boolean ping(RequestOptions options) throws java.io.IOException
Pings the remote Elasticsearch cluster and returns true if the ping succeeded, false otherwise- Parameters:
options
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
true
if the ping succeeded, false otherwise- Throws:
java.io.IOException
- in case there is a problem sending the request
-
ping
@Deprecated public final boolean ping(org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Preferping(RequestOptions)
Pings the remote Elasticsearch cluster and returns true if the ping succeeded, false otherwise- Throws:
java.io.IOException
-
info
public final MainResponse info(RequestOptions options) throws java.io.IOException
Get the cluster info otherwise provided when sending an HTTP request to '/'- Parameters:
options
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
info
@Deprecated public final MainResponse info(org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Preferinfo(RequestOptions)
Get the cluster info otherwise provided when sending an HTTP request to port 9200- Throws:
java.io.IOException
-
get
public final GetResponse get(GetRequest getRequest, RequestOptions options) throws java.io.IOException
Retrieves a document by id using the Get API. See Get API on elastic.co- Parameters:
getRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
get
@Deprecated public final GetResponse get(GetRequest getRequest, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Retrieves a document by id using the Get API. See Get API on elastic.co- Throws:
java.io.IOException
-
getAsync
public final void getAsync(GetRequest getRequest, RequestOptions options, ActionListener<GetResponse> listener)
Asynchronously retrieves a document by id using the Get API. See Get API on elastic.co- Parameters:
getRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
getAsync
@Deprecated public final void getAsync(GetRequest getRequest, ActionListener<GetResponse> listener, org.apache.http.Header... headers)
Deprecated.Asynchronously retrieves a document by id using the Get API. See Get API on elastic.co
-
multiGet
@Deprecated public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, RequestOptions options) throws java.io.IOException
Deprecated.usemget(MultiGetRequest, RequestOptions)
insteadRetrieves multiple documents by id using the Multi Get API. See Multi Get API on elastic.co- Parameters:
multiGetRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
mget
public final MultiGetResponse mget(MultiGetRequest multiGetRequest, RequestOptions options) throws java.io.IOException
Retrieves multiple documents by id using the Multi Get API. See Multi Get API on elastic.co- Parameters:
multiGetRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
multiGet
@Deprecated public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Retrieves multiple documents by id using the Multi Get API. See Multi Get API on elastic.co- Throws:
java.io.IOException
-
multiGetAsync
@Deprecated public final void multiGetAsync(MultiGetRequest multiGetRequest, RequestOptions options, ActionListener<MultiGetResponse> listener)
Deprecated.Asynchronously retrieves multiple documents by id using the Multi Get API. See Multi Get API on elastic.co- Parameters:
multiGetRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
mgetAsync
public final void mgetAsync(MultiGetRequest multiGetRequest, RequestOptions options, ActionListener<MultiGetResponse> listener)
Asynchronously retrieves multiple documents by id using the Multi Get API. See Multi Get API on elastic.co- Parameters:
multiGetRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
multiGetAsync
@Deprecated public final void multiGetAsync(MultiGetRequest multiGetRequest, ActionListener<MultiGetResponse> listener, org.apache.http.Header... headers)
Deprecated.Asynchronously retrieves multiple documents by id using the Multi Get API. See Multi Get API on elastic.co
-
exists
public final boolean exists(GetRequest getRequest, RequestOptions options) throws java.io.IOException
Checks for the existence of a document. Returns true if it exists, false otherwise. See Get API on elastic.co- Parameters:
getRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
true
if the document exists,false
otherwise- Throws:
java.io.IOException
- in case there is a problem sending the request
-
exists
@Deprecated public final boolean exists(GetRequest getRequest, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Checks for the existence of a document. Returns true if it exists, false otherwise. See Get API on elastic.co- Throws:
java.io.IOException
-
existsAsync
public final void existsAsync(GetRequest getRequest, RequestOptions options, ActionListener<java.lang.Boolean> listener)
Asynchronously checks for the existence of a document. Returns true if it exists, false otherwise. See Get API on elastic.co- Parameters:
getRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
existsAsync
@Deprecated public final void existsAsync(GetRequest getRequest, ActionListener<java.lang.Boolean> listener, org.apache.http.Header... headers)
Deprecated.Asynchronously checks for the existence of a document. Returns true if it exists, false otherwise. See Get API on elastic.co
-
index
public final IndexResponse index(IndexRequest indexRequest, RequestOptions options) throws java.io.IOException
Index a document using the Index API. See Index API on elastic.co- Parameters:
indexRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
index
@Deprecated public final IndexResponse index(IndexRequest indexRequest, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Index a document using the Index API. See Index API on elastic.co- Throws:
java.io.IOException
-
indexAsync
public final void indexAsync(IndexRequest indexRequest, RequestOptions options, ActionListener<IndexResponse> listener)
Asynchronously index a document using the Index API. See Index API on elastic.co- Parameters:
indexRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
indexAsync
@Deprecated public final void indexAsync(IndexRequest indexRequest, ActionListener<IndexResponse> listener, org.apache.http.Header... headers)
Deprecated.Asynchronously index a document using the Index API. See Index API on elastic.co
-
update
public final UpdateResponse update(UpdateRequest updateRequest, RequestOptions options) throws java.io.IOException
Updates a document using the Update API. See Update API on elastic.co- Parameters:
updateRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
update
@Deprecated public final UpdateResponse update(UpdateRequest updateRequest, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Updates a document using the Update API.- Throws:
java.io.IOException
-
updateAsync
public final void updateAsync(UpdateRequest updateRequest, RequestOptions options, ActionListener<UpdateResponse> listener)
Asynchronously updates a document using the Update API. See Update API on elastic.co- Parameters:
updateRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
updateAsync
@Deprecated public final void updateAsync(UpdateRequest updateRequest, ActionListener<UpdateResponse> listener, org.apache.http.Header... headers)
Deprecated.Asynchronously updates a document using the Update API.
-
delete
public final DeleteResponse delete(DeleteRequest deleteRequest, RequestOptions options) throws java.io.IOException
Deletes a document by id using the Delete API. See Delete API on elastic.co- Parameters:
deleteRequest
- the reuqestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
delete
@Deprecated public final DeleteResponse delete(DeleteRequest deleteRequest, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Deletes a document by id using the Delete API. See Delete API on elastic.co- Throws:
java.io.IOException
-
deleteAsync
public final void deleteAsync(DeleteRequest deleteRequest, RequestOptions options, ActionListener<DeleteResponse> listener)
Asynchronously deletes a document by id using the Delete API. See Delete API on elastic.co- Parameters:
deleteRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
deleteAsync
@Deprecated public final void deleteAsync(DeleteRequest deleteRequest, ActionListener<DeleteResponse> listener, org.apache.http.Header... headers)
Deprecated.Asynchronously deletes a document by id using the Delete API. See Delete API on elastic.co
-
search
public final SearchResponse search(SearchRequest searchRequest, RequestOptions options) throws java.io.IOException
Executes a search request using the Search API. See Search API on elastic.co- Parameters:
searchRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
search
@Deprecated public final SearchResponse search(SearchRequest searchRequest, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Executes a search using the Search API. See Search API on elastic.co- Throws:
java.io.IOException
-
searchAsync
public final void searchAsync(SearchRequest searchRequest, RequestOptions options, ActionListener<SearchResponse> listener)
Asynchronously executes a search using the Search API. See Search API on elastic.co- Parameters:
searchRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
searchAsync
@Deprecated public final void searchAsync(SearchRequest searchRequest, ActionListener<SearchResponse> listener, org.apache.http.Header... headers)
Deprecated.Asynchronously executes a search using the Search API. See Search API on elastic.co
-
multiSearch
@Deprecated public final MultiSearchResponse multiSearch(MultiSearchRequest multiSearchRequest, RequestOptions options) throws java.io.IOException
Deprecated.usemsearch(MultiSearchRequest, RequestOptions)
insteadExecutes a multi search using the msearch API. See Multi search API on elastic.co- Parameters:
multiSearchRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
msearch
public final MultiSearchResponse msearch(MultiSearchRequest multiSearchRequest, RequestOptions options) throws java.io.IOException
Executes a multi search using the msearch API. See Multi search API on elastic.co- Parameters:
multiSearchRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
multiSearch
@Deprecated public final MultiSearchResponse multiSearch(MultiSearchRequest multiSearchRequest, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Executes a multi search using the msearch API. See Multi search API on elastic.co- Throws:
java.io.IOException
-
multiSearchAsync
@Deprecated public final void multiSearchAsync(MultiSearchRequest searchRequest, RequestOptions options, ActionListener<MultiSearchResponse> listener)
Deprecated.Asynchronously executes a multi search using the msearch API. See Multi search API on elastic.co- Parameters:
searchRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
msearchAsync
public final void msearchAsync(MultiSearchRequest searchRequest, RequestOptions options, ActionListener<MultiSearchResponse> listener)
Asynchronously executes a multi search using the msearch API. See Multi search API on elastic.co- Parameters:
searchRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
multiSearchAsync
@Deprecated public final void multiSearchAsync(MultiSearchRequest searchRequest, ActionListener<MultiSearchResponse> listener, org.apache.http.Header... headers)
Deprecated.Asynchronously executes a multi search using the msearch API. See Multi search API on elastic.co
-
searchScroll
@Deprecated public final SearchResponse searchScroll(SearchScrollRequest searchScrollRequest, RequestOptions options) throws java.io.IOException
Deprecated.usescroll(SearchScrollRequest, RequestOptions)
insteadExecutes a search using the Search Scroll API. See Search Scroll API on elastic.co- Parameters:
searchScrollRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
scroll
public final SearchResponse scroll(SearchScrollRequest searchScrollRequest, RequestOptions options) throws java.io.IOException
Executes a search using the Search Scroll API. See Search Scroll API on elastic.co- Parameters:
searchScrollRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
searchScroll
@Deprecated public final SearchResponse searchScroll(SearchScrollRequest searchScrollRequest, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Executes a search using the Search Scroll API. See Search Scroll API on elastic.co- Throws:
java.io.IOException
-
searchScrollAsync
@Deprecated public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, RequestOptions options, ActionListener<SearchResponse> listener)
Deprecated.Asynchronously executes a search using the Search Scroll API. See Search Scroll API on elastic.co- Parameters:
searchScrollRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
scrollAsync
public final void scrollAsync(SearchScrollRequest searchScrollRequest, RequestOptions options, ActionListener<SearchResponse> listener)
Asynchronously executes a search using the Search Scroll API. See Search Scroll API on elastic.co- Parameters:
searchScrollRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
searchScrollAsync
@Deprecated public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, ActionListener<SearchResponse> listener, org.apache.http.Header... headers)
Deprecated.Asynchronously executes a search using the Search Scroll API. See Search Scroll API on elastic.co
-
clearScroll
public final ClearScrollResponse clearScroll(ClearScrollRequest clearScrollRequest, RequestOptions options) throws java.io.IOException
Clears one or more scroll ids using the Clear Scroll API. See Clear Scroll API on elastic.co- Parameters:
clearScrollRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
clearScroll
@Deprecated public final ClearScrollResponse clearScroll(ClearScrollRequest clearScrollRequest, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Clears one or more scroll ids using the Clear Scroll API. See Clear Scroll API on elastic.co- Throws:
java.io.IOException
-
clearScrollAsync
public final void clearScrollAsync(ClearScrollRequest clearScrollRequest, RequestOptions options, ActionListener<ClearScrollResponse> listener)
Asynchronously clears one or more scroll ids using the Clear Scroll API. See Clear Scroll API on elastic.co- Parameters:
clearScrollRequest
- the reuqestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
clearScrollAsync
@Deprecated public final void clearScrollAsync(ClearScrollRequest clearScrollRequest, ActionListener<ClearScrollResponse> listener, org.apache.http.Header... headers)
Deprecated.Asynchronously clears one or more scroll ids using the Clear Scroll API. See Clear Scroll API on elastic.co
-
searchTemplate
public final SearchTemplateResponse searchTemplate(SearchTemplateRequest searchTemplateRequest, RequestOptions options) throws java.io.IOException
Executes a request using the Search Template API. See Search Template API on elastic.co.- Parameters:
searchTemplateRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
searchTemplateAsync
public final void searchTemplateAsync(SearchTemplateRequest searchTemplateRequest, RequestOptions options, ActionListener<SearchTemplateResponse> listener)
Asynchronously executes a request using the Search Template API. See Search Template API on elastic.co.
-
explain
public final ExplainResponse explain(ExplainRequest explainRequest, RequestOptions options) throws java.io.IOException
Executes a request using the Explain API. See Explain API on elastic.co- Parameters:
explainRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
explainAsync
public final void explainAsync(ExplainRequest explainRequest, RequestOptions options, ActionListener<ExplainResponse> listener)
Asynchronously executes a request using the Explain API. See Explain API on elastic.co- Parameters:
explainRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
rankEval
public final RankEvalResponse rankEval(RankEvalRequest rankEvalRequest, RequestOptions options) throws java.io.IOException
Executes a request using the Ranking Evaluation API. See Ranking Evaluation API on elastic.co- Parameters:
rankEvalRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
rankEval
@Deprecated public final RankEvalResponse rankEval(RankEvalRequest rankEvalRequest, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.Executes a request using the Ranking Evaluation API. See Ranking Evaluation API on elastic.co- Throws:
java.io.IOException
-
rankEvalAsync
public final void rankEvalAsync(RankEvalRequest rankEvalRequest, RequestOptions options, ActionListener<RankEvalResponse> listener)
Asynchronously executes a request using the Ranking Evaluation API. See Ranking Evaluation API on elastic.co- Parameters:
rankEvalRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
msearchTemplate
public final MultiSearchTemplateResponse msearchTemplate(MultiSearchTemplateRequest multiSearchTemplateRequest, RequestOptions options) throws java.io.IOException
Executes a request using the Multi Search Template API. See Multi Search Template API on elastic.co.- Throws:
java.io.IOException
-
msearchTemplateAsync
public final void msearchTemplateAsync(MultiSearchTemplateRequest multiSearchTemplateRequest, RequestOptions options, ActionListener<MultiSearchTemplateResponse> listener)
Asynchronously executes a request using the Multi Search Template API See Multi Search Template API on elastic.co.
-
rankEvalAsync
@Deprecated public final void rankEvalAsync(RankEvalRequest rankEvalRequest, ActionListener<RankEvalResponse> listener, org.apache.http.Header... headers)
Deprecated.Asynchronously executes a request using the Ranking Evaluation API. See Ranking Evaluation API on elastic.co
-
fieldCaps
public final FieldCapabilitiesResponse fieldCaps(FieldCapabilitiesRequest fieldCapabilitiesRequest, RequestOptions options) throws java.io.IOException
Executes a request using the Field Capabilities API. See Field Capabilities API on elastic.co.- Parameters:
fieldCapabilitiesRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
getScript
public GetStoredScriptResponse getScript(GetStoredScriptRequest request, RequestOptions options) throws java.io.IOException
Get stored script by id. See How to use scripts on elastic.co- Parameters:
request
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
getScriptAsync
public void getScriptAsync(GetStoredScriptRequest request, RequestOptions options, ActionListener<GetStoredScriptResponse> listener)
Asynchronously get stored script by id. See How to use scripts on elastic.co- Parameters:
request
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
deleteScript
public DeleteStoredScriptResponse deleteScript(DeleteStoredScriptRequest request, RequestOptions options) throws java.io.IOException
Delete stored script by id. See How to use scripts on elastic.co- Parameters:
request
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customized- Returns:
- the response
- Throws:
java.io.IOException
- in case there is a problem sending the request or parsing back the response
-
deleteScriptAsync
public void deleteScriptAsync(DeleteStoredScriptRequest request, RequestOptions options, ActionListener<DeleteStoredScriptResponse> listener)
Asynchronously delete stored script by id. See How to use scripts on elastic.co- Parameters:
request
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
fieldCapsAsync
public final void fieldCapsAsync(FieldCapabilitiesRequest fieldCapabilitiesRequest, RequestOptions options, ActionListener<FieldCapabilitiesResponse> listener)
Asynchronously executes a request using the Field Capabilities API. See Field Capabilities API on elastic.co.- Parameters:
fieldCapabilitiesRequest
- the requestoptions
- the request options (e.g. headers), useRequestOptions.DEFAULT
if nothing needs to be customizedlistener
- the listener to be notified upon request completion
-
performRequestAndParseEntity
@Deprecated protected final <Req extends ActionRequest,Resp> Resp performRequestAndParseEntity(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, CheckedFunction<XContentParser,Resp,java.io.IOException> entityParser, java.util.Set<java.lang.Integer> ignores, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.- Throws:
java.io.IOException
-
performRequestAndParseEntity
protected final <Req extends ActionRequest,Resp> Resp performRequestAndParseEntity(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, RequestOptions options, CheckedFunction<XContentParser,Resp,java.io.IOException> entityParser, java.util.Set<java.lang.Integer> ignores) throws java.io.IOException
- Throws:
java.io.IOException
-
performRequest
@Deprecated protected final <Req extends ActionRequest,Resp> Resp performRequest(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, CheckedFunction<Response,Resp,java.io.IOException> responseConverter, java.util.Set<java.lang.Integer> ignores, org.apache.http.Header... headers) throws java.io.IOException
Deprecated.- Throws:
java.io.IOException
-
performRequest
protected final <Req extends ActionRequest,Resp> Resp performRequest(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, RequestOptions options, CheckedFunction<Response,Resp,java.io.IOException> responseConverter, java.util.Set<java.lang.Integer> ignores) throws java.io.IOException
- Throws:
java.io.IOException
-
performRequestAsyncAndParseEntity
@Deprecated protected final <Req extends ActionRequest,Resp> void performRequestAsyncAndParseEntity(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, CheckedFunction<XContentParser,Resp,java.io.IOException> entityParser, ActionListener<Resp> listener, java.util.Set<java.lang.Integer> ignores, org.apache.http.Header... headers)
Deprecated.
-
performRequestAsyncAndParseEntity
protected final <Req extends ActionRequest,Resp> void performRequestAsyncAndParseEntity(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, RequestOptions options, CheckedFunction<XContentParser,Resp,java.io.IOException> entityParser, ActionListener<Resp> listener, java.util.Set<java.lang.Integer> ignores)
-
performRequestAsync
@Deprecated protected final <Req extends ActionRequest,Resp> void performRequestAsync(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, CheckedFunction<Response,Resp,java.io.IOException> responseConverter, ActionListener<Resp> listener, java.util.Set<java.lang.Integer> ignores, org.apache.http.Header... headers)
Deprecated.
-
performRequestAsync
protected final <Req extends ActionRequest,Resp> void performRequestAsync(Req request, CheckedFunction<Req,Request,java.io.IOException> requestConverter, RequestOptions options, CheckedFunction<Response,Resp,java.io.IOException> responseConverter, ActionListener<Resp> listener, java.util.Set<java.lang.Integer> ignores)
-
parseResponseException
protected final ElasticsearchStatusException parseResponseException(ResponseException responseException)
Converts aResponseException
obtained from the low level REST client into anElasticsearchException
. If a response body was returned, tries to parse it as an error returned from Elasticsearch. If no response body was returned or anything goes wrong while parsing the error, returns a newElasticsearchStatusException
that wraps the originalResponseException
. The potential exception obtained while parsing is added to the returned exception as a suppressed exception. This method is guaranteed to not throw any exception eventually thrown while parsing.
-
parseEntity
protected final <Resp> Resp parseEntity(org.apache.http.HttpEntity entity, CheckedFunction<XContentParser,Resp,java.io.IOException> entityParser) throws java.io.IOException
- Throws:
java.io.IOException
-
-