Skip to content

Commit

Permalink
fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
ElPicador committed Aug 23, 2017
1 parent 0bf1a71 commit 73f304e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ Task deleteBy(String indexName, Query query, RequestOptions requestOptions) thro
)
.setData(query);

return httpClient.requestWithRetry(algoliaRequest);
return httpClient.requestWithRetry(algoliaRequest).setIndex(indexName).setAPIClient(this);
}

TaskSingleIndex partialUpdateObjects(String indexName, List<Object> objects, RequestOptions requestOptions) throws AlgoliaException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ interface DeleteByQuery<T> extends BaseSyncIndex<T> {

/**
* Delete records matching a query, with a batch size of 1000, internally uses browse
* Deprecated, use deleteBy
* @deprecated, use deleteBy
*
* @param query The query
* @throws AlgoliaException
Expand All @@ -1455,7 +1455,7 @@ default Task deleteBy(@Nonnull Query query) throws AlgoliaException {

/**
* Delete records matching a query, with a batch size of 1000, internally uses browse
* Deprecated, use deleteBy
* @deprecated, use deleteBy
*
* @param query The query
* @param requestOptions Options to pass to this request
Expand All @@ -1468,7 +1468,6 @@ default void deleteByQuery(@Nonnull Query query, @Nonnull RequestOptions request

/**
* Delete records matching a query
* Deprecated, use deleteBy
*
* @param query The query
* @param requestOptions Options to pass to this request
Expand All @@ -1480,7 +1479,7 @@ default Task deleteBy(@Nonnull Query query, @Nonnull RequestOptions requestOptio

/**
* Delete records matching a query, internally uses browse
* Deprecated use deleteBy
* @deprecated use deleteBy
*
* @param query The query
* @param batchSize the size of the batches
Expand All @@ -1493,7 +1492,7 @@ default void deleteByQuery(@Nonnull Query query, int batchSize) throws AlgoliaEx

/**
* Delete records matching a query, internally uses browse
* Deprecated use deleteBy
* @deprecated use deleteBy
*
* @param query The query
* @param batchSize the size of the batches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand All @@ -38,11 +39,11 @@ public void deleteBy() throws Exception {
List<AlgoliaObject> objects = IntStream.rangeClosed(1, 10).mapToObj(i -> new AlgoliaObject("name" + i, i)).collect(Collectors.toList());
waitForCompletion(index.addObjects(objects));

waitForCompletion(index.deleteBy(new Query("")));
waitForCompletion(index.deleteBy(new Query().setTagFilters(Collections.singletonList("a"))));

SearchResult<AlgoliaObject> search = index.search(new Query("")).get();

assertThat(search.getHits()).isEmpty();
assertThat(search.getHits()).hasSize(10);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -66,9 +67,9 @@ public void deleteBy() throws AlgoliaException {
List<AlgoliaObject> objects = IntStream.rangeClosed(1, 10).mapToObj(i -> new AlgoliaObject("name" + i, i)).collect(Collectors.toList());
index.addObjects(objects).waitForCompletion();

index.deleteBy(new Query("")).waitForCompletion();
index.deleteBy(new Query().setTagFilters(Collections.singletonList("a"))).waitForCompletion();

assertThat(index.search(new Query("")).getHits()).isEmpty();
assertThat(index.search(new Query("")).getHits()).hasSize(10);
}

}

0 comments on commit 73f304e

Please sign in to comment.