Created
November 2, 2022 09:00
-
-
Save NGhebreial/9ba8c6b05ddc4e94499bbfcfce86a09e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs'; | |
import algoliasearch from 'algoliasearch'; | |
const IDS_FILE = './query_results.csv'; | |
const indexName = ''; // The index we want | |
const client = algoliasearch('', ''); // The credentials | |
const index = client.initIndex(indexName); | |
const objectIds = fs.readFileSync(IDS_FILE, 'utf8').trim().split('\n').filter(x => /\d/.test(x)).map(x => x.replace(/"/g, '')); | |
index.deleteObjects(objectIds).then(({ objectIDs }) => { | |
console.log(`Sucessfully deleted ${objectIDs.length} documents`); | |
process.exit(); | |
}).catch(e => console.log(e)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment