|
1 | | -gem 'algolia', '=2.3.4' |
2 | 1 | require 'json' |
3 | 2 | require 'algolia' |
4 | 3 | require 'open-uri' |
|
13 | 12 | download = URI.open(indexUrl) |
14 | 13 | IO.copy_stream(download, indexFile) |
15 | 14 |
|
16 | | -client = Algolia::Search::Client.create(appId, apiKey) |
17 | | -index = client.init_index(indexName) |
| 15 | +client = Algolia::SearchClient.create(appId, apiKey) |
18 | 16 | file = File.read(indexFile) |
19 | 17 | records = JSON.parse(file) |
20 | 18 |
|
21 | 19 | # The API client automatically batches your records |
22 | | -index.replace_all_objects(records, {}) |
| 20 | +client.replace_all_objects(indexName, records) |
23 | 21 |
|
24 | 22 | # Apply settings from config file |
25 | 23 | configFile = File.read('.github/workflows/algolia-config.json') |
26 | 24 | config = JSON.parse(configFile) |
27 | 25 |
|
28 | | -index.set_settings(config['settings']) |
| 26 | +client.set_settings(indexName, config['settings']) |
29 | 27 |
|
30 | 28 | # Apply synonyms if present |
31 | 29 | if config['synonyms'] && !config['synonyms'].empty? |
32 | | - index.save_synonyms(config['synonyms'], { replaceExistingSynonyms: true }) |
| 30 | + client.save_synonyms(indexName, config['synonyms'], nil, true) |
33 | 31 | end |
34 | 32 |
|
35 | 33 | # Apply rules if present |
36 | 34 | if config['rules'] && !config['rules'].empty? |
37 | | - index.save_rules(config['rules'], { clearExistingRules: true }) |
| 35 | + client.save_rules(indexName, config['rules'], nil, true) |
38 | 36 | end |
0 commit comments