Skip to content

Commit 6813d55

Browse files
committed
ruby
1 parent af94766 commit 6813d55

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

templates/ruby/search_helpers.mustache

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,11 @@ end
341341
# @param index_name [String] The `index_name` to replace `objects` in.
342342
# @param objects [Array] The array of `objects` to store in the given Algolia `index_name`.
343343
# @param batch_size [int] The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
344+
# @param scopes [Array] The `scopes` to keep from the index. Defaults to `['settings', 'rules', 'synonyms']`.
344345
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
345346
#
346347
# @return [Array<ReplaceAllObjectsResponse>]
347-
def replace_all_objects(index_name, objects, batch_size = 1000, request_options = {})
348+
def replace_all_objects(index_name, objects, batch_size = 1000, scopes = [Search::ScopeType::SETTINGS, Search::ScopeType::RULES, Search::ScopeType::SYNONYMS], request_options = {})
348349
tmp_index_name = index_name + '_tmp_' + rand(10_000_000).to_s
349350

350351
begin
@@ -353,11 +354,7 @@ def replace_all_objects(index_name, objects, batch_size = 1000, request_options
353354
Search::OperationIndexParams.new(
354355
operation: Search::OperationType::COPY,
355356
destination: tmp_index_name,
356-
scope: [
357-
Search::ScopeType::SETTINGS,
358-
Search::ScopeType::RULES,
359-
Search::ScopeType::SYNONYMS
360-
]
357+
scope: scopes
361358
),
362359
request_options
363360
)
@@ -378,11 +375,7 @@ def replace_all_objects(index_name, objects, batch_size = 1000, request_options
378375
Search::OperationIndexParams.new(
379376
operation: Search::OperationType::COPY,
380377
destination: tmp_index_name,
381-
scope: [
382-
Search::ScopeType::SETTINGS,
383-
Search::ScopeType::RULES,
384-
Search::ScopeType::SYNONYMS
385-
]
378+
scope: scopes
386379
),
387380
request_options
388381
)

0 commit comments

Comments
 (0)