IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Exists API
editExists API
editThe exists API returns true
if a document exists, and false
otherwise.
Exists Request
editIt uses GetRequest
just like the Get API.
All of its optional arguments
are supported. Since exists()
only returns true
or false
, we recommend
turning off fetching _source
and any stored fields so the request is
slightly lighter:
Synchronous Execution
editboolean exists = client.exists(getRequest, RequestOptions.DEFAULT);
Asynchronous Execution
editThe asynchronous execution of exists request requires both the GetRequest
instance and an ActionListener
instance to be passed to the asynchronous
method:
The asynchronous method does not block and returns immediately. Once it is
completed the ActionListener
is called back using the onResponse
method
if the execution successfully completed or using the onFailure
method if
it failed.
A typical listener for GetResponse
looks like: