From d40e54223787e345f2f9f8aad012d0a757111017 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Fri, 3 Nov 2023 18:01:58 +0000 Subject: [PATCH] add script for deleting tags --- index-delete.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 index-delete.js diff --git a/index-delete.js b/index-delete.js new file mode 100644 index 0000000..ba01548 --- /dev/null +++ b/index-delete.js @@ -0,0 +1,38 @@ +import AlgoliaSearch from 'algoliasearch'; + +import 'dotenv/config' + +let client = null; +let index = null; + +const { ALGOLIA_APP_ID, ALGOLIA_ADMIN_KEY } = process.env + +function init(indexName) { + if (!client) client = AlgoliaSearch(ALGOLIA_APP_ID, ALGOLIA_ADMIN_KEY); + + return client.initIndex(indexName); +} + +const params = { + "facets": [ + "version", + ], + "facetFilters": [ + [ + "_tags:version:5.4.0" + ] + ], +}; + +index = init('methods'); + +// index.search('', params).then((results) => { +// const {hits} = results; +// console.log(hits.length, results); +// }).catch(console.log); + + +index.deleteBy('', params).then((results) => { + const {hits} = results; + console.log(hits, results); +}).catch(console.log); \ No newline at end of file