api-clients-automation
api-clients-automation copied to clipboard
Documentation missing in Java documentation: how to clear an index before sending new data to Algolia
Description
It's unclear now what is the best method to clear an index before sending new data.
I used this approach, but it's not clear to me if this will be executed in the correct order:
List<BatchRequest> requests = new ArrayList<>();
requests.add(new BatchRequest().setAction(Action.CLEAR));
for (ContentSection section : sections) {
requests.add(new BatchRequest()
.setAction(Action.ADD_OBJECT)
.setBody(section)
);
}
BatchResponse response = client.batch(ALGOLIA_INDEX, new BatchWriteParams().setRequests(requests));
client.waitForTask(ALGOLIA_INDEX, response.getTaskID());
Steps to reproduce
This page: https://api-clients-automation.netlify.app/docs/clients/guides/send-data-to-algolia
Environment
- Java API
Hey, thanks for reporting, the easiest way to remove all records is with:
UpdatedAtResponse response = client.clearObjects("myIndexName");
client.waitForTask("myIndexName", response.getTaskID());
We will add a page to the documentation :)