Created
May 19, 2020 12:36
-
-
Save ogawa0071/18b6dcfee2d26000248e4a071ce349d0 to your computer and use it in GitHub Desktop.
Algolia Index Export
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
| 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!"); | |
| } | |
| ); | |
| }); |
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
| { | |
| "dependencies": { | |
| "algoliasearch": "^4.2.0" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment