@@ -479,7 +479,6 @@ public Request getObjectsAsync(final @NonNull List<String> objectIDs, final List
479
479
* @param taskID Identifier of the task (as returned by the server).
480
480
* @param completionHandler The listener that will be notified of the request's outcome.
481
481
* @return A cancellable request.
482
- *
483
482
* @deprecated Task IDs are always integers. Please use {@link #waitTaskAsync(int, CompletionHandler)} instead.
484
483
*/
485
484
public Request waitTaskAsync (final @ NonNull String taskID , @ NonNull CompletionHandler completionHandler ) {
@@ -541,11 +540,12 @@ public Request deleteObjectsAsync(final @NonNull List<String> objectIDs, Complet
541
540
}
542
541
543
542
/**
544
- * Delete all objects matching a query (helper).
543
+ * Delete all objects matching a query (helper) using browse and deleteObjects .
545
544
*
546
545
* @param query The query that objects to delete must match.
547
546
* @param completionHandler The listener that will be notified of the request's outcome.
548
547
* @return A cancellable request.
548
+ * @deprecated use {@link Index#deleteByAsync(Query, CompletionHandler)} instead.
549
549
*/
550
550
public Request deleteByQueryAsync (@ NonNull Query query , CompletionHandler completionHandler ) {
551
551
final Query queryCopy = new Query (query );
@@ -558,6 +558,23 @@ public Request deleteByQueryAsync(@NonNull Query query, CompletionHandler comple
558
558
}.start ();
559
559
}
560
560
561
+ /**
562
+ * Delete all objects matching a query (helper).
563
+ *
564
+ * @param query The query that objects to delete must match.
565
+ * @param completionHandler The listener that will be notified of the request's outcome.
566
+ * @return A cancellable request.
567
+ */
568
+ public Request deleteByAsync (@ NonNull Query query , CompletionHandler completionHandler ) {
569
+ final Query queryCopy = new Query (query );
570
+ return getClient ().new AsyncTaskRequest (completionHandler ) {
571
+ @ NonNull
572
+ @ Override protected JSONObject run () throws AlgoliaException {
573
+ return deleteBy (queryCopy );
574
+ }
575
+ }.start ();
576
+ }
577
+
561
578
/**
562
579
* Get this index's settings (asynchronously).
563
580
*
@@ -960,11 +977,13 @@ protected JSONObject deleteObjects(List<String> objects) throws AlgoliaException
960
977
}
961
978
962
979
/**
963
- * Delete all objects matching a query
980
+ * Delete all objects matching a query using browse and deleteObjects.
964
981
*
965
982
* @param query the query string
966
983
* @throws AlgoliaException
984
+ * @deprecated use {@link Index#deleteBy(Query)} instead.
967
985
*/
986
+ @ Deprecated
968
987
protected void deleteByQuery (@ NonNull Query query ) throws AlgoliaException {
969
988
try {
970
989
boolean hasMore ;
@@ -990,6 +1009,21 @@ protected void deleteByQuery(@NonNull Query query) throws AlgoliaException {
990
1009
}
991
1010
}
992
1011
1012
+ /**
1013
+ * Delete all records matching the query.
1014
+ *
1015
+ * @param query the query string
1016
+ * @throws AlgoliaException
1017
+ */
1018
+ protected JSONObject deleteBy (@ NonNull Query query ) throws AlgoliaException {
1019
+ try {
1020
+ return client .postRequest ("/1/indexes/" + indexName + "/deleteByQuery" , new JSONObject ().put ("params" , query .build ()).toString (), false );
1021
+ } catch (JSONException e ) {
1022
+ e .printStackTrace ();
1023
+ return null ;
1024
+ }
1025
+ }
1026
+
993
1027
/**
994
1028
* Search inside the index
995
1029
*
0 commit comments