public class RestHighLevelClient
extends java.lang.Object
RestClient
and allows to build requests and read responses.
The provided RestClient
is externally built and closed.
Can 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.Modifier | Constructor and Description |
---|---|
|
RestHighLevelClient(RestClient restClient)
Creates a
RestHighLevelClient given the low level RestClient that it should use to perform requests. |
protected |
RestHighLevelClient(RestClient restClient,
java.util.List<NamedXContentRegistry.Entry> namedXContentEntries)
Creates a
RestHighLevelClient given the low level RestClient that it should use to perform requests and
a list of entries that allow to parse custom response sections added to Elasticsearch through plugins. |
Modifier and Type | Method and Description |
---|---|
BulkResponse |
bulk(BulkRequest bulkRequest,
org.apache.http.Header... headers)
Executes a bulk request using the Bulk API
See Bulk API on elastic.co
|
void |
bulkAsync(BulkRequest bulkRequest,
ActionListener<BulkResponse> listener,
org.apache.http.Header... headers)
Asynchronously executes a bulk request using the Bulk API
See Bulk API on elastic.co
|
ClearScrollResponse |
clearScroll(ClearScrollRequest clearScrollRequest,
org.apache.http.Header... headers)
Clears one or more scroll ids using the Clear Scroll api
See
Clear Scroll API on elastic.co
|
void |
clearScrollAsync(ClearScrollRequest clearScrollRequest,
ActionListener<ClearScrollResponse> listener,
org.apache.http.Header... headers)
Asynchronously clears one or more scroll ids using the Clear Scroll api
See
Clear Scroll API on elastic.co
|
DeleteResponse |
delete(DeleteRequest deleteRequest,
org.apache.http.Header... headers)
Deletes a document by id using the Delete api
See Delete API on elastic.co
|
void |
deleteAsync(DeleteRequest deleteRequest,
ActionListener<DeleteResponse> listener,
org.apache.http.Header... headers)
Asynchronously deletes a document by id using the Delete api
See Delete API on elastic.co
|
boolean |
exists(GetRequest getRequest,
org.apache.http.Header... headers)
Checks for the existence of a document.
|
void |
existsAsync(GetRequest getRequest,
ActionListener<java.lang.Boolean> listener,
org.apache.http.Header... headers)
Asynchronously checks for the existence of a document.
|
GetResponse |
get(GetRequest getRequest,
org.apache.http.Header... headers)
Retrieves a document by id using the Get API
See Get API on elastic.co
|
void |
getAsync(GetRequest getRequest,
ActionListener<GetResponse> listener,
org.apache.http.Header... headers)
Asynchronously retrieves a document by id using the Get API
See Get API on elastic.co
|
IndexResponse |
index(IndexRequest indexRequest,
org.apache.http.Header... headers)
Index a document using the Index API
See Index API on elastic.co
|
void |
indexAsync(IndexRequest indexRequest,
ActionListener<IndexResponse> listener,
org.apache.http.Header... headers)
Asynchronously index a document using the Index API
See Index API on elastic.co
|
MainResponse |
info(org.apache.http.Header... headers)
Get the cluster info otherwise provided when sending an HTTP request to port 9200
|
protected <Req extends ActionRequest,Resp> |
performRequest(Req request,
CheckedFunction<Req,org.elasticsearch.client.Request,java.io.IOException> requestConverter,
CheckedFunction<Response,Resp,java.io.IOException> responseConverter,
java.util.Set<java.lang.Integer> ignores,
org.apache.http.Header... headers) |
protected <Req extends ActionRequest,Resp> |
performRequestAndParseEntity(Req request,
CheckedFunction<Req,org.elasticsearch.client.Request,java.io.IOException> requestConverter,
CheckedFunction<XContentParser,Resp,java.io.IOException> entityParser,
java.util.Set<java.lang.Integer> ignores,
org.apache.http.Header... headers) |
protected <Req extends ActionRequest,Resp> |
performRequestAsync(Req request,
CheckedFunction<Req,org.elasticsearch.client.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) |
protected <Req extends ActionRequest,Resp> |
performRequestAsyncAndParseEntity(Req request,
CheckedFunction<Req,org.elasticsearch.client.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) |
boolean |
ping(org.apache.http.Header... headers)
Pings the remote Elasticsearch cluster and returns true if the ping succeeded, false otherwise
|
SearchResponse |
search(SearchRequest searchRequest,
org.apache.http.Header... headers)
Executes a search using the Search api
See Search API on elastic.co
|
void |
searchAsync(SearchRequest searchRequest,
ActionListener<SearchResponse> listener,
org.apache.http.Header... headers)
Asynchronously executes a search using the Search api
See Search API on elastic.co
|
SearchResponse |
searchScroll(SearchScrollRequest searchScrollRequest,
org.apache.http.Header... headers)
Executes a search using the Search Scroll api
See Search Scroll
API on elastic.co
|
void |
searchScrollAsync(SearchScrollRequest searchScrollRequest,
ActionListener<SearchResponse> listener,
org.apache.http.Header... headers)
Asynchronously executes a search using the Search Scroll api
See Search Scroll
API on elastic.co
|
UpdateResponse |
update(UpdateRequest updateRequest,
org.apache.http.Header... headers)
Updates a document using the Update API
|
void |
updateAsync(UpdateRequest updateRequest,
ActionListener<UpdateResponse> listener,
org.apache.http.Header... headers)
Asynchronously updates a document using the Update API
|
public RestHighLevelClient(RestClient restClient)
RestHighLevelClient
given the low level RestClient
that it should use to perform requests.protected RestHighLevelClient(RestClient restClient, java.util.List<NamedXContentRegistry.Entry> namedXContentEntries)
RestHighLevelClient
given the low level RestClient
that it should use to perform requests and
a list of entries that allow to parse custom response sections added to Elasticsearch through plugins.public BulkResponse bulk(BulkRequest bulkRequest, org.apache.http.Header... headers) throws java.io.IOException
java.io.IOException
public void bulkAsync(BulkRequest bulkRequest, ActionListener<BulkResponse> listener, org.apache.http.Header... headers)
public boolean ping(org.apache.http.Header... headers) throws java.io.IOException
java.io.IOException
public MainResponse info(org.apache.http.Header... headers) throws java.io.IOException
java.io.IOException
public GetResponse get(GetRequest getRequest, org.apache.http.Header... headers) throws java.io.IOException
java.io.IOException
public void getAsync(GetRequest getRequest, ActionListener<GetResponse> listener, org.apache.http.Header... headers)
public boolean exists(GetRequest getRequest, org.apache.http.Header... headers) throws java.io.IOException
java.io.IOException
public void existsAsync(GetRequest getRequest, ActionListener<java.lang.Boolean> listener, org.apache.http.Header... headers)
public IndexResponse index(IndexRequest indexRequest, org.apache.http.Header... headers) throws java.io.IOException
java.io.IOException
public void indexAsync(IndexRequest indexRequest, ActionListener<IndexResponse> listener, org.apache.http.Header... headers)
public UpdateResponse update(UpdateRequest updateRequest, org.apache.http.Header... headers) throws java.io.IOException
java.io.IOException
public void updateAsync(UpdateRequest updateRequest, ActionListener<UpdateResponse> listener, org.apache.http.Header... headers)
public DeleteResponse delete(DeleteRequest deleteRequest, org.apache.http.Header... headers) throws java.io.IOException
java.io.IOException
public void deleteAsync(DeleteRequest deleteRequest, ActionListener<DeleteResponse> listener, org.apache.http.Header... headers)
public SearchResponse search(SearchRequest searchRequest, org.apache.http.Header... headers) throws java.io.IOException
java.io.IOException
public void searchAsync(SearchRequest searchRequest, ActionListener<SearchResponse> listener, org.apache.http.Header... headers)
public SearchResponse searchScroll(SearchScrollRequest searchScrollRequest, org.apache.http.Header... headers) throws java.io.IOException
java.io.IOException
public void searchScrollAsync(SearchScrollRequest searchScrollRequest, ActionListener<SearchResponse> listener, org.apache.http.Header... headers)
public ClearScrollResponse clearScroll(ClearScrollRequest clearScrollRequest, org.apache.http.Header... headers) throws java.io.IOException
java.io.IOException
public void clearScrollAsync(ClearScrollRequest clearScrollRequest, ActionListener<ClearScrollResponse> listener, org.apache.http.Header... headers)
protected <Req extends ActionRequest,Resp> Resp performRequestAndParseEntity(Req request, CheckedFunction<Req,org.elasticsearch.client.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
java.io.IOException
protected <Req extends ActionRequest,Resp> Resp performRequest(Req request, CheckedFunction<Req,org.elasticsearch.client.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
java.io.IOException
protected <Req extends ActionRequest,Resp> void performRequestAsyncAndParseEntity(Req request, CheckedFunction<Req,org.elasticsearch.client.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)
protected <Req extends ActionRequest,Resp> void performRequestAsync(Req request, CheckedFunction<Req,org.elasticsearch.client.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)