delete_by_query
The functiondelete_by_query(collection_name, body) deletes all documents that match the query conditions
Input-
collection_name – Specifies the Collection with the documents to delete
body– The query that specifies the documents to delete
Example-
hyperspace_client.delete_by_query(collection_name,
body = {"query": {
"bool": {
"must": {
"term": {
"department": "IT"
},
}
}
})
String queryJson =
"{" +
" \"query\": {" +
" \"bool\": {" +
" \"must\": [" +
" {" +
" \"term\":{" +
" \"department\":\"IT\"" +
" }" +
" }" +
" ]" +
" }" +
" }" +
"}";
JsonObject query = JsonParser.parseString(queryJson).getAsJsonObject();
DeleteByQueryRequest queryRequest = new DeleteByQueryRequest();
queryRequest.setQuery(query);
DeleteByQueryResponse response = client.deleteByQuery(collectionName, queryRequest);
System.out.println(response.getTook());
System.out.println(response.getDeleted());await hyperspaceClient.deleteByQuery({
index: collectionName,
body: {
query: {
bool: {
must: {
term: {
department: "IT"
},
}
}
}
}
})Last updated