@@ -657,7 +657,6 @@ public Request getObjectsAsync(final @NonNull List<String> objectIDs, final List
657
657
* @param taskID Identifier of the task (as returned by the server).
658
658
* @param completionHandler The listener that will be notified of the request's outcome.
659
659
* @return A cancellable request.
660
- *
661
660
* @deprecated Task IDs are always integers. Please use {@link #waitTaskAsync(int, CompletionHandler)} instead.
662
661
*/
663
662
public Request waitTaskAsync (final @ NonNull String taskID , @ NonNull CompletionHandler completionHandler ) {
@@ -743,11 +742,12 @@ public Request deleteObjectsAsync(final @NonNull List<String> objectIDs, @Nullab
743
742
}
744
743
745
744
/**
746
- * Delete all objects matching a query (helper).
745
+ * Delete all objects matching a query (helper) using browse and deleteObjects .
747
746
*
748
747
* @param query The query that objects to delete must match.
749
748
* @param completionHandler The listener that will be notified of the request's outcome.
750
749
* @return A cancellable request.
750
+ * @deprecated use {@link Index#deleteByAsync(Query, CompletionHandler)} instead.
751
751
*/
752
752
public Request deleteByQueryAsync (@ NonNull Query query , CompletionHandler completionHandler ) {
753
753
return deleteByQueryAsync (query , /* requestOptions: */ null , completionHandler );
@@ -772,6 +772,23 @@ public Request deleteByQueryAsync(@NonNull Query query, @Nullable final RequestO
772
772
}.start ();
773
773
}
774
774
775
+ /**
776
+ * Delete all objects matching a query (helper).
777
+ *
778
+ * @param query The query that objects to delete must match.
779
+ * @param completionHandler The listener that will be notified of the request's outcome.
780
+ * @return A cancellable request.
781
+ */
782
+ public Request deleteByAsync (@ NonNull Query query , CompletionHandler completionHandler ) {
783
+ final Query queryCopy = new Query (query );
784
+ return getClient ().new AsyncTaskRequest (completionHandler ) {
785
+ @ NonNull
786
+ @ Override protected JSONObject run () throws AlgoliaException {
787
+ return deleteBy (queryCopy );
788
+ }
789
+ }.start ();
790
+ }
791
+
775
792
/**
776
793
* Get this index's settings (asynchronously).
777
794
*
@@ -1238,12 +1255,14 @@ protected JSONObject deleteObjects(List<String> objects, @Nullable RequestOption
1238
1255
}
1239
1256
1240
1257
/**
1241
- * Delete all objects matching a query
1258
+ * Delete all objects matching a query using browse and deleteObjects.
1242
1259
*
1243
1260
* @param query the query string
1244
1261
* @param requestOptions Request-specific options.
1245
1262
* @throws AlgoliaException
1263
+ * @deprecated use {@link Index#deleteBy(Query)} instead.
1246
1264
*/
1265
+ @ Deprecated
1247
1266
protected void deleteByQuery (@ NonNull Query query , @ Nullable RequestOptions requestOptions ) throws AlgoliaException {
1248
1267
try {
1249
1268
boolean hasMore ;
@@ -1269,6 +1288,21 @@ protected void deleteByQuery(@NonNull Query query, @Nullable RequestOptions requ
1269
1288
}
1270
1289
}
1271
1290
1291
+ /**
1292
+ * Delete all records matching the query.
1293
+ *
1294
+ * @param query the query string
1295
+ * @throws AlgoliaException
1296
+ */
1297
+ protected JSONObject deleteBy (@ NonNull Query query ) throws AlgoliaException {
1298
+ try {
1299
+ return client .postRequest ("/1/indexes/" + indexName + "/deleteByQuery" , query .getParameters (), new JSONObject ().put ("params" , query .build ()).toString (), false , /* requestOptions: */ null );
1300
+ } catch (JSONException e ) {
1301
+ e .printStackTrace ();
1302
+ return null ;
1303
+ }
1304
+ }
1305
+
1272
1306
/**
1273
1307
* Search inside the index
1274
1308
*
0 commit comments