SDK
SDK Java v3.x
2

This SDK is deprecated. We recommend to use the Kuzzle SDK-JVM.
A migration guide is available here

deleteByQuery #

Deletes documents matching the provided search query.

Kuzzle uses the ElasticSearch Query DSL syntax.

An empty or null query will match all documents in the collection.


Copied to clipboard!
  public CompletableFuture<ArrayList<String>> deleteByQuery(
      final String index,
      final String collection,
      final ConcurrentHashMap<String, Object> searchQuery) throws NotConnectedException, InternalException

  public CompletableFuture<ArrayList<String>> deleteByQuery(
      final String index,
      final String collection,
      final ConcurrentHashMap<String, Object> searchQuery,
      final Boolean waitForRefresh) throws NotConnectedException, InternalException
Argument Type Description
index
String
Index name
collection
String
Collection name
searchQuery
ConcurrentHashMap<String, Object>
Query to match
waitForRefresh
Boolean
(optional)
If set to true, Kuzzle will wait for the persistence layer to finish indexing

Returns #

Returns an ArrayList<String> containing the deleted document ids.

Usage #

Copied to clipboard!
ConcurrentHashMap<String, Object> searchQuery = new ConcurrentHashMap<>();
ConcurrentHashMap<String, Object> query = new ConcurrentHashMap<>();
ConcurrentHashMap<String, Object> match = new ConcurrentHashMap<>();
match.put("capacity", 4);
query.put("match", match);
searchQuery.put("query", query);
ArrayList<String> result = kuzzle
  .getDocumentController()
  .deleteByQuery("nyc-open-data", "yellow-taxi", searchQuery)
  .get();