@@ -3150,19 +3150,21 @@ def wait_for_app_task(
3150
3150
def wait_for_api_key (
3151
3151
key ,
3152
3152
operation ,
3153
- api_key = { } ,
3153
+ api_key = Search :: ApiKey . new ,
3154
3154
max_retries = 50 ,
3155
3155
timeout = -> ( retry_count ) { [ retry_count * 200 , 5000 ] . min } ,
3156
3156
request_options = { }
3157
3157
)
3158
+ api_key = api_client . object_to_hash ( api_key )
3159
+
3158
3160
retries = 0
3159
3161
if operation == "update"
3160
3162
raise ArgumentError , "`api_key` is required when waiting for an `update` operation." if api_key . nil?
3161
3163
while retries < max_retries
3162
3164
updated_key = get_api_key ( key , request_options )
3163
3165
updated_key_hash = updated_key . to_hash
3164
3166
equals = true
3165
- api_key . to_hash . each do |k , v |
3167
+ api_key . each do |k , v |
3166
3168
equals &&= updated_key_hash [ k ] == v
3167
3169
end
3168
3170
@@ -3201,7 +3203,9 @@ def wait_for_api_key(
3201
3203
# @param request_options [Hash] the requestOptions to send along with the query, they will be forwarded to the `browse` method.
3202
3204
# @param block [Proc] the block to execute on each object of the index.
3203
3205
def browse_objects ( index_name , browse_params = Search ::BrowseParamsObject . new , request_options = { } , &block )
3204
- browse_params . hits_per_page ||= 1000
3206
+ browse_params = api_client . object_to_hash ( browse_params )
3207
+
3208
+ browse_params [ :hitsPerPage ] = 1000 unless browse_params . key? ( :hitsPerPage )
3205
3209
3206
3210
hits = [ ]
3207
3211
loop do
@@ -3214,8 +3218,8 @@ def browse_objects(index_name, browse_params = Search::BrowseParamsObject.new, r
3214
3218
hits . concat ( res . hits )
3215
3219
end
3216
3220
3217
- browse_params . cursor = res . cursor
3218
- break if browse_params . cursor . nil?
3221
+ browse_params [ : cursor] = res . cursor
3222
+ break if browse_params [ : cursor] . nil?
3219
3223
end
3220
3224
3221
3225
hits unless block_given?
@@ -3227,12 +3231,11 @@ def browse_objects(index_name, browse_params = Search::BrowseParamsObject.new, r
3227
3231
# @param search_rules_params [SearchRulesParams] the parameters to send along with the query, they will be forwarded to the `searchRules` method.
3228
3232
# @param request_options [Hash] the requestOptions to send along with the query, they will be forwarded to the `searchRules` method.
3229
3233
# @param block [Proc] the block to execute on each rule of the index.
3230
- def browse_rules (
3231
- index_name ,
3232
- search_rules_params = Search ::SearchRulesParams . new ( hits_per_page : 1000 , page : 0 ) ,
3233
- request_options = { } ,
3234
- &block
3235
- )
3234
+ def browse_rules ( index_name , search_rules_params = Search ::SearchRulesParams . new , request_options = { } , &block )
3235
+ search_rules_params = api_client . object_to_hash ( search_rules_params )
3236
+
3237
+ search_rules_params [ :hitsPerPage ] = 1000 unless search_rules_params . key? ( :hitsPerPage )
3238
+
3236
3239
rules = [ ]
3237
3240
loop do
3238
3241
res = search_rules ( index_name , search_rules_params , request_options )
@@ -3244,8 +3247,8 @@ def browse_rules(
3244
3247
rules . concat ( res . hits )
3245
3248
end
3246
3249
3247
- search_rules_params . page += 1
3248
- break if res . hits . length < search_rules_params . hits_per_page
3250
+ search_rules_params [ : page] += 1
3251
+ break if res . hits . length < search_rules_params [ :hitsPerPage ]
3249
3252
end
3250
3253
3251
3254
rules unless block_given?
@@ -3259,10 +3262,14 @@ def browse_rules(
3259
3262
# @param block [Proc] the block to execute on each synonym of the index.
3260
3263
def browse_synonyms (
3261
3264
index_name ,
3262
- search_synonyms_params = Search ::SearchSynonymsParams . new ( hits_per_page : 1000 , page : 0 ) ,
3265
+ search_synonyms_params = Search ::SearchSynonymsParams . new ,
3263
3266
request_options = { } ,
3264
3267
&block
3265
3268
)
3269
+ search_synonyms_params = api_client . object_to_hash ( search_synonyms_params )
3270
+
3271
+ search_synonyms_params [ :hitsPerPage ] = 1000 unless search_synonyms_params . key? ( :hitsPerPage )
3272
+
3266
3273
synonyms = [ ]
3267
3274
loop do
3268
3275
res = search_synonyms ( index_name , search_synonyms_params , request_options )
@@ -3274,8 +3281,8 @@ def browse_synonyms(
3274
3281
synonyms . concat ( res . hits )
3275
3282
end
3276
3283
3277
- search_synonyms_params . page += 1
3278
- break if res . hits . length < search_synonyms_params . hits_per_page
3284
+ search_synonyms_params [ : page] += 1
3285
+ break if res . hits . length < search_synonyms_params [ :hitsPerPage ]
3279
3286
end
3280
3287
3281
3288
synonyms unless block_given?
@@ -3543,6 +3550,5 @@ def index_exists?(index_name)
3543
3550
3544
3551
true
3545
3552
end
3546
-
3547
3553
end
3548
3554
end
0 commit comments