Mass Delete with filter

I am using Algolia for search purposes and we got a huge pile of records. We want to delete some records and have decided to delete records that are older than X date.

First I was using this

const records = [];
const deleteRecordsBeforeDateAlgolia = (date) => {
    let client;


    const index = client.initIndex('function_message');
    //get the records before the given date
    try {'',{
            filters: `time_stamp < ${date}`
        }).then(({hits}) => {
            if(hits.length > 0) {
                for (const hit of hits) {
            if(hits.length === 0) {
                console.log(`Deleted ${records.length} records`);
            } else {
    } catch (err) {

but I realized this isnt that optimized + will be very slow when deleting on prod. Can you tell me how I can get huge amounts of data with a filter (timestamp in this case) and then delete all of them? also want all of this to be synchronous

Hi! For retrieving large amounts of records for a batch operation like this, you’ll want browseObjects instead of a searching.

You can include a filter for the data range. You can also limit the response to just the objectIDs, then pass the array of objectIds to deleteObjects for batch deletion.