Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation missing in Java documentation: how to clear an index before sending new data to Algolia #1164

Open
FDelporte opened this issue Dec 7, 2022 · 1 comment
Labels
Java Issue related to the Java client

Comments

@FDelporte
Copy link

FDelporte commented Dec 7, 2022

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
@FDelporte FDelporte changed the title Documentation missing in Java documentation: how to clear an index before sending new to send data to Algolia Documentation missing in Java documentation: how to clear an index before sending new data to Algolia Dec 7, 2022
@millotp
Copy link
Collaborator

millotp commented Dec 7, 2022

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 :)

@shortcuts shortcuts added the Java Issue related to the Java client label Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java Issue related to the Java client
Projects
None yet
Development

No branches or pull requests

3 participants