Skip to content

Instantly share code, notes, and snippets.

@ogawa0071
Created May 19, 2020 12:36
Show Gist options
  • Select an option

  • Save ogawa0071/18b6dcfee2d26000248e4a071ce349d0 to your computer and use it in GitHub Desktop.

Select an option

Save ogawa0071/18b6dcfee2d26000248e4a071ce349d0 to your computer and use it in GitHub Desktop.
Algolia Index Export
const algoliasearch = require("algoliasearch");
const client = algoliasearch("MKXB4H37FU", "");
const index = client.initIndex("game_index_production");
const fs = require("fs");
let hits = [];
index
.browseObjects({
batch: (objects) => (hits = hits.concat(objects)),
})
.then(() => {
console.log("Finished!");
console.log("We got %d hits", hits.length);
fs.writeFile(
"browse.json",
JSON.stringify(hits, null, 2),
"utf-8",
(err) => {
if (err) throw err;
console.log("Your index has been exported!");
}
);
});
{
"dependencies": {
"algoliasearch": "^4.2.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment