Last active
June 30, 2023 18:20
-
-
Save denvit/72463d4f9cc90ee33c29a808d9caacbd to your computer and use it in GitHub Desktop.
Ruby script to get a list of records in Algolia index
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
# 1. Install ruby using brew | |
# 3. Run in terminal: gem install algoliasearch | |
# 4. Run this script in terminal: ruby script.rb | |
require 'json' | |
require 'algoliasearch' | |
Algolia.init(application_id: '<insert id here>', api_key: '<insert admin key here>') | |
index = Algolia::Index.new('< name of your index >') | |
hits = [] | |
index.browse({ query: '', attributesToRetrieve: ['objectID', 'name', 'sku'] }) do |hit| | |
hits.push(hit) | |
end | |
File.write('algolia_records.json', hits.to_json) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment