Class: Algolia::SearchClient

Inherits:
Object
  • Object
show all
Defined in:
lib/algolia/api/search_client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ SearchClient

Returns a new instance of SearchClient.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/algolia/api/search_client.rb', line 55

def initialize(config = nil)
  raise "`config` is missing." if config.nil?
  raise "`app_id` is missing." if config.app_id.nil? || config.app_id == ""
  raise "`api_key` is missing." if config.api_key.nil? || config.api_key == ""

  if config.connect_timeout.nil?
    config.connect_timeout = 2000
  end

  if config.read_timeout.nil?
    config.read_timeout = 5000
  end

  if config.write_timeout.nil?
    config.write_timeout = 30000
  end

  # Per-client capability; an explicit config.request_id_enabled always wins.
  @api_client = Algolia::ApiClient.new(config, request_id_support: true)
  @ingestion_transporter = nil
  if config.transformation_options
    @ingestion_transporter = _build_ingestion_transporter(config.transformation_options)
  end
end

Instance Attribute Details

#api_client ⇒ Object

Returns the value of attribute api_client.



53
54
55
# File 'lib/algolia/api/search_client.rb', line 53

def api_client
  @api_client
end

Class Method Details

.create(app_id, api_key, opts = {}) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/algolia/api/search_client.rb', line 80

def self.create(app_id, api_key, opts = {})
  hosts = []
  hosts << Transport::StatefulHost.new("#{app_id}-dsn.algolia.net", accept: CallType::READ)
  hosts << Transport::StatefulHost.new("#{app_id}.algolia.net", accept: CallType::WRITE)

  hosts += 1
    .upto(3)
    .map do |i|
      Transport::StatefulHost.new("#{app_id}-#{i}.algolianet.com", accept: CallType::READ | CallType::WRITE)
    end
    .shuffle

  config = Algolia::Configuration.new(app_id, api_key, hosts, "Search", opts)
  new(config)
end

.create_with_config(config) ⇒ Object



96
97
98
# File 'lib/algolia/api/search_client.rb', line 96

def self.create_with_config(config)
  new(config)
end

.generate_secured_api_key(parent_api_key, restrictions = {}) ⇒ String

Helper: Generates a secured API key based on the given parent_api_key and given restrictions.

Parameters:

  • parent_api_key (String) —

    Parent API key used the generate the secured key

  • restrictions (SecuredApiKeyRestrictions) (defaults to: {}) —

    Restrictions to apply on the secured key

Returns:

  • (String)


3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
# File 'lib/algolia/api/search_client.rb', line 3937

def self.generate_secured_api_key(parent_api_key, restrictions = {})
  restrictions = restrictions.to_hash
  if restrictions.key?(:searchParams)
    # merge searchParams with the root of the restrictions

    restrictions.merge!(restrictions[:searchParams])
    restrictions.delete(:searchParams)
  end

  url_encoded_restrictions = Algolia::Transport
    .stringify_query_params(restrictions)
    .sort
    .to_h
    .map do |key, value|
      "#{key}=#{value}"
    end
    .join("&")

  hmac = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), parent_api_key, url_encoded_restrictions)
  Base64.encode64("#{hmac}#{url_encoded_restrictions}").gsub("\n", "")
end

.get_secured_api_key_remaining_validity(secured_api_key) ⇒ Integer

Helper: Retrieves the remaining validity of the previous generated secured_api_key, the validUntil parameter must have been provided.

Parameters:

  • secured_api_key (String)

Returns:

  • (Integer)


3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
# File 'lib/algolia/api/search_client.rb', line 3976

def self.get_secured_api_key_remaining_validity(secured_api_key)
  now = Time.now.to_i
  decoded_key = Base64.decode64(secured_api_key)
  regex = "validUntil=(\\d+)"
  matches = decoded_key.match(regex)

  if matches.nil?
    raise AlgoliaError, "The SecuredApiKey doesn't have a validUntil parameter."
  end

  valid_until = matches[1].to_i

  valid_until - now
end

.with_transformation(app_id, api_key, transformation_options, opts = {}) ⇒ SearchClient

Creates a SearchClient configured with a TransformationOptions for use with *_with_transformation helpers. The ingestion transporter is initialised eagerly using Ingestion API defaults (25s timeouts); set override fields on TransformationOptions to change specific defaults. See https://www.algolia.com/doc/libraries/ruby/v3/methods/ingestion

Parameters:

  • app_id (String) —

    the Algolia application ID. (required)

  • api_key (String) —

    the Algolia API key. (required)

  • transformation_options (TransformationOptions) —

    the transformation options including region and optional ingestion transporter overrides. (required)

  • opts (Hash) (defaults to: {}) —

    additional configuration options passed to the search client. (optional)

Returns:



111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/algolia/api/search_client.rb', line 111

def self.with_transformation(app_id, api_key, transformation_options, opts = {})
  opts = opts.dup
  hosts = opts.delete(:hosts)
  if hosts
    config = Algolia::Configuration.new(app_id, api_key, hosts, "Search", opts)
    client = new(config)
  else
    client = create(app_id, api_key, opts)
  end

  client.set_transformation_options(transformation_options)
  client
end

Instance Method Details

#_build_ingestion_transporter(transformation_options) ⇒ Object

The parent search config MUST NOT leak into the ingestion transporter.



3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
# File 'lib/algolia/api/search_client.rb', line 3453

def _build_ingestion_transporter(transformation_options)
  hosts = if transformation_options.hosts
    transformation_options.hosts
  else
    [
      Transport::StatefulHost.new(
        "data.#{transformation_options.region}.algolia.com",
        accept: CallType::READ | CallType::WRITE
      )
    ]
  end

  opts = {}
  unless transformation_options.connect_timeout.nil?
    opts[:connect_timeout] = transformation_options.connect_timeout
  end

  opts[:read_timeout] = transformation_options.read_timeout unless transformation_options.read_timeout.nil?
  opts[:write_timeout] = transformation_options.write_timeout unless transformation_options.write_timeout.nil?
  unless transformation_options.compression_type.nil?
    opts[:compression_type] = transformation_options.compression_type
  end

  config = Algolia::Configuration.new(
    @api_client.config.app_id,
    @api_client.config.api_key,
    hosts,
    "Ingestion",
    opts
  )

  if transformation_options.header_params
    config.header_params = config.header_params.merge(transformation_options.header_params)
  end

  Algolia::IngestionClient.create_with_config(config)
end

#add_api_key(api_key, request_options = {}) ⇒ AddApiKeyResponse

Creates a new API key with specific permissions and restrictions.

Required API Key ACLs:

- admin

Parameters:

  • api_key (ApiKey) —

    (required)

  • 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)

Returns:

  • (AddApiKeyResponse)


180
181
182
183
# File 'lib/algolia/api/search_client.rb', line 180

def add_api_key(api_key, request_options = {})
  response = add_api_key_with_http_info(api_key, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::AddApiKeyResponse")
end

#add_api_key_with_http_info(api_key, request_options = {}) ⇒ Http::Response

Creates a new API key with specific permissions and restrictions.

Required API Key ACLs:

- admin

Parameters:

  • api_key (ApiKey) —

    (required)

  • 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)

Returns:



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/algolia/api/search_client.rb', line 148

def add_api_key_with_http_info(api_key, request_options = {})
  # verify the required parameter 'api_key' is set
  if @api_client.config.client_side_validation && api_key.nil?
    raise ArgumentError, "Parameter `api_key` is required when calling `add_api_key`."
  end

  path = "/1/keys"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(api_key)

  new_options = request_options.merge(
    :operation => :"SearchClient.add_api_key",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#add_or_update_object(index_name, algolia_object_id, body, request_options = {}) ⇒ UpdatedAtWithObjectIdResponse

If a record with the specified object ID exists, the existing record is replaced. Otherwise, a new record is added to the index. If you want to use auto-generated object IDs, use the saveObject operation. To update some attributes of an existing record, use the partial operation instead. To add, update, or replace multiple records, use the batch operation.

Required API Key ACLs:

- addObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique record identifier. (required)

  • body (Object) —

    The record. A schemaless object with attributes that are useful in the context of search and discovery. (required)

  • 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)

Returns:

  • (UpdatedAtWithObjectIdResponse)


247
248
249
250
251
252
253
# File 'lib/algolia/api/search_client.rb', line 247

def add_or_update_object(index_name, algolia_object_id, body, request_options = {})
  response = add_or_update_object_with_http_info(index_name, algolia_object_id, body, request_options)
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Search::UpdatedAtWithObjectIdResponse"
  )
end

#add_or_update_object_with_http_info(index_name, algolia_object_id, body, request_options = {}) ⇒ Http::Response

If a record with the specified object ID exists, the existing record is replaced. Otherwise, a new record is added to the index. If you want to use auto-generated object IDs, use the saveObject operation. To update some attributes of an existing record, use the partial operation instead. To add, update, or replace multiple records, use the batch operation.

Required API Key ACLs:

- addObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique record identifier. (required)

  • body (Object) —

    The record. A schemaless object with attributes that are useful in the context of search and discovery. (required)

  • 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)

Returns:



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/algolia/api/search_client.rb', line 194

def add_or_update_object_with_http_info(index_name, algolia_object_id, body, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `add_or_update_object`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `add_or_update_object`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `add_or_update_object`."
  end
  # verify the required parameter 'algolia_object_id' is not empty
  if @api_client.config.client_side_validation && algolia_object_id.empty?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `add_or_update_object`."
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    raise ArgumentError, "Parameter `body` is required when calling `add_or_update_object`."
  end

  path = "/1/indexes/{indexName}/{objectID}".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s)).sub(
    "{" + "objectID" + "}",
    Transport.encode_uri(algolia_object_id.to_s)
  )
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(body)

  new_options = request_options.merge(
    :operation => :"SearchClient.add_or_update_object",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#add_user_agent_segment(segment, version = nil) ⇒ Object



135
136
137
138
139
# File 'lib/algolia/api/search_client.rb', line 135

def add_user_agent_segment(segment, version = nil)
  @api_client.config.add_user_agent_segment(segment, version)

  self
end

#append_source(source, request_options = {}) ⇒ CreatedAtResponse

Adds a source to the list of allowed sources.

Required API Key ACLs:

- admin

Parameters:

  • source (Source) —

    Source to add. (required)

  • 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)

Returns:

  • (CreatedAtResponse)


294
295
296
297
# File 'lib/algolia/api/search_client.rb', line 294

def append_source(source, request_options = {})
  response = append_source_with_http_info(source, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::CreatedAtResponse")
end

#append_source_with_http_info(source, request_options = {}) ⇒ Http::Response

Adds a source to the list of allowed sources.

Required API Key ACLs:

- admin

Parameters:

  • source (Source) —

    Source to add. (required)

  • 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)

Returns:



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/algolia/api/search_client.rb', line 262

def append_source_with_http_info(source, request_options = {})
  # verify the required parameter 'source' is set
  if @api_client.config.client_side_validation && source.nil?
    raise ArgumentError, "Parameter `source` is required when calling `append_source`."
  end

  path = "/1/security/sources/append"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(source)

  new_options = request_options.merge(
    :operation => :"SearchClient.append_source",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#assert_ingestion_transporter! ⇒ Object



3499
3500
3501
3502
3503
3504
3505
3506
# File 'lib/algolia/api/search_client.rb', line 3499

def assert_ingestion_transporter!
  if @ingestion_transporter.nil?
    raise(
      ArgumentError,
      "`transformation_options` must be set in the client config before calling this method. It defaults to the Ingestion API defaults. See https://www.algolia.com/doc/libraries/ruby/v3/methods/ingestion/"
    )
  end
end

#assign_user_id(x_algolia_user_id, assign_user_id_params, request_options = {}) ⇒ CreatedAtResponse

Assigns or moves a user ID to a cluster. The time it takes to move a user is proportional to the amount of data linked to the user ID.

Required API Key ACLs:

- admin

Parameters:

  • x_algolia_user_id (String) —

    Unique identifier of the user who makes the search request. (required)

  • assign_user_id_params (AssignUserIdParams) —

    (required)

  • 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)

Returns:

  • (CreatedAtResponse)


350
351
352
353
# File 'lib/algolia/api/search_client.rb', line 350

def assign_user_id(x_algolia_user_id, assign_user_id_params, request_options = {})
  response = assign_user_id_with_http_info(x_algolia_user_id, assign_user_id_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::CreatedAtResponse")
end

#assign_user_id_with_http_info(x_algolia_user_id, assign_user_id_params, request_options = {}) ⇒ Http::Response

Assigns or moves a user ID to a cluster. The time it takes to move a user is proportional to the amount of data linked to the user ID.

Required API Key ACLs:

- admin

THIS OPERATION IS DEPRECATED

Parameters:

  • x_algolia_user_id (String) —

    Unique identifier of the user who makes the search request. (required)

  • assign_user_id_params (AssignUserIdParams) —

    (required)

  • 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)

Returns:



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/algolia/api/search_client.rb', line 308

def assign_user_id_with_http_info(x_algolia_user_id, assign_user_id_params, request_options = {})
  # verify the required parameter 'x_algolia_user_id' is set
  if @api_client.config.client_side_validation && x_algolia_user_id.nil?
    raise ArgumentError, "Parameter `x_algolia_user_id` is required when calling `assign_user_id`."
  end
  # verify the required parameter 'x_algolia_user_id' is not empty
  if @api_client.config.client_side_validation && x_algolia_user_id.empty?
    raise ArgumentError, "Parameter `x_algolia_user_id` is required when calling `assign_user_id`."
  end
  # verify the required parameter 'assign_user_id_params' is set
  if @api_client.config.client_side_validation && assign_user_id_params.nil?
    raise ArgumentError, "Parameter `assign_user_id_params` is required when calling `assign_user_id`."
  end

  path = "/1/clusters/mapping"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params[:"X-Algolia-User-ID"] = x_algolia_user_id
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(assign_user_id_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.assign_user_id",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#batch(index_name, batch_write_params, request_options = {}) ⇒ BatchResponse

Adds, updates, or deletes records in one index with a single API request. Batching index updates reduces latency and increases data integrity. - Actions are applied in the order they're specified. - Actions are equivalent to the individual API requests of the same name. This operation is subject to indexing rate limits.

Required API Key ACLs:

- addObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • batch_write_params (BatchWriteParams) —

    (required)

  • 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)

Returns:

  • (BatchResponse)


404
405
406
407
# File 'lib/algolia/api/search_client.rb', line 404

def batch(index_name, batch_write_params, request_options = {})
  response = batch_with_http_info(index_name, batch_write_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::BatchResponse")
end

#batch_assign_user_ids(x_algolia_user_id, batch_assign_user_ids_params, request_options = {}) ⇒ CreatedAtResponse

Assigns multiple user IDs to a cluster. You can't move users with this operation.

Required API Key ACLs:

- admin

Parameters:

  • x_algolia_user_id (String) —

    Unique identifier of the user who makes the search request. (required)

  • batch_assign_user_ids_params (BatchAssignUserIdsParams) —

    (required)

  • 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)

Returns:

  • (CreatedAtResponse)


463
464
465
466
# File 'lib/algolia/api/search_client.rb', line 463

def batch_assign_user_ids(x_algolia_user_id, batch_assign_user_ids_params, request_options = {})
  response = batch_assign_user_ids_with_http_info(x_algolia_user_id, batch_assign_user_ids_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::CreatedAtResponse")
end

#batch_assign_user_ids_with_http_info(x_algolia_user_id, batch_assign_user_ids_params, request_options = {}) ⇒ Http::Response

Assigns multiple user IDs to a cluster. You can't move users with this operation.

Required API Key ACLs:

- admin

THIS OPERATION IS DEPRECATED

Parameters:

  • x_algolia_user_id (String) —

    Unique identifier of the user who makes the search request. (required)

  • batch_assign_user_ids_params (BatchAssignUserIdsParams) —

    (required)

  • 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)

Returns:



418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/algolia/api/search_client.rb', line 418

def batch_assign_user_ids_with_http_info(x_algolia_user_id, batch_assign_user_ids_params, request_options = {})
  # verify the required parameter 'x_algolia_user_id' is set
  if @api_client.config.client_side_validation && x_algolia_user_id.nil?
    raise ArgumentError, "Parameter `x_algolia_user_id` is required when calling `batch_assign_user_ids`."
  end
  # verify the required parameter 'x_algolia_user_id' is not empty
  if @api_client.config.client_side_validation && x_algolia_user_id.empty?
    raise ArgumentError, "Parameter `x_algolia_user_id` is required when calling `batch_assign_user_ids`."
  end
  # verify the required parameter 'batch_assign_user_ids_params' is set
  if @api_client.config.client_side_validation && batch_assign_user_ids_params.nil?
    raise(
      ArgumentError,
      "Parameter `batch_assign_user_ids_params` is required when calling `batch_assign_user_ids`."
    )
  end

  path = "/1/clusters/mapping/batch"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params[:"X-Algolia-User-ID"] = x_algolia_user_id
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(batch_assign_user_ids_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.batch_assign_user_ids",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#batch_dictionary_entries(dictionary_name, batch_dictionary_entries_params, request_options = {}) ⇒ UpdatedAtResponse

Adds or deletes multiple entries from your plurals, segmentation, or stop word dictionaries.

Required API Key ACLs:

- editSettings

Parameters:

  • dictionary_name (DictionaryType) —

    Dictionary type in which to search. (required)

  • batch_dictionary_entries_params (BatchDictionaryEntriesParams) —

    (required)

  • 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)

Returns:

  • (UpdatedAtResponse)


519
520
521
522
523
524
525
526
# File 'lib/algolia/api/search_client.rb', line 519

def batch_dictionary_entries(dictionary_name, batch_dictionary_entries_params, request_options = {})
  response = batch_dictionary_entries_with_http_info(
    dictionary_name,
    batch_dictionary_entries_params,
    request_options
  )
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
end

#batch_dictionary_entries_with_http_info(dictionary_name, batch_dictionary_entries_params, request_options = {}) ⇒ Http::Response

Adds or deletes multiple entries from your plurals, segmentation, or stop word dictionaries.

Required API Key ACLs:

- editSettings

Parameters:

  • dictionary_name (DictionaryType) —

    Dictionary type in which to search. (required)

  • batch_dictionary_entries_params (BatchDictionaryEntriesParams) —

    (required)

  • 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)

Returns:



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/algolia/api/search_client.rb', line 476

def batch_dictionary_entries_with_http_info(dictionary_name, batch_dictionary_entries_params, request_options = {})
  # verify the required parameter 'dictionary_name' is set
  if @api_client.config.client_side_validation && dictionary_name.nil?
    raise ArgumentError, "Parameter `dictionary_name` is required when calling `batch_dictionary_entries`."
  end
  # verify the required parameter 'batch_dictionary_entries_params' is set
  if @api_client.config.client_side_validation && batch_dictionary_entries_params.nil?
    raise(
      ArgumentError,
      "Parameter `batch_dictionary_entries_params` is required when calling `batch_dictionary_entries`."
    )
  end

  path = "/1/dictionaries/{dictionaryName}/batch".sub(
    "{" + "dictionaryName" + "}",
    Transport.encode_uri(dictionary_name.to_s)
  )
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(batch_dictionary_entries_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.batch_dictionary_entries",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#batch_with_http_info(index_name, batch_write_params, request_options = {}) ⇒ Http::Response

Adds, updates, or deletes records in one index with a single API request. Batching index updates reduces latency and increases data integrity. - Actions are applied in the order they're specified. - Actions are equivalent to the individual API requests of the same name. This operation is subject to indexing rate limits.

Required API Key ACLs:

- addObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • batch_write_params (BatchWriteParams) —

    (required)

  • 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)

Returns:



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# File 'lib/algolia/api/search_client.rb', line 363

def batch_with_http_info(index_name, batch_write_params, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `batch`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `batch`."
  end
  # verify the required parameter 'batch_write_params' is set
  if @api_client.config.client_side_validation && batch_write_params.nil?
    raise ArgumentError, "Parameter `batch_write_params` is required when calling `batch`."
  end

  path = "/1/indexes/{indexName}/batch".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(batch_write_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.batch",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#browse(index_name, browse_params = nil, request_options = {}) ⇒ BrowseResponse

Retrieves records from an index, up to 1,000 per request. Searching returns hits (records augmented with highlighting and ranking details). Browsing returns matching records only. Use browse to export your indices. - The Analytics API doesn't collect data when using browse. - Records are ranked by attributes and custom ranking. - There's no ranking for typo tolerance, number of matched words, proximity, or geo distance. Browse requests automatically apply these settings: - advancedSyntax: false - attributesToHighlight: [] - attributesToSnippet: [] - distinct: false - enablePersonalization: false - enableRules: false - facets: [] - getRankingInfo: false - ignorePlurals: false - optionalFilters: [] - typoTolerance: true or false (min and strict evaluate to true) If you send these parameters with your browse requests, they're ignored.

Required API Key ACLs:

- browse

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • browse_params (BrowseParams) (defaults to: nil)
  • 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)

Returns:

  • (BrowseResponse)


573
574
575
576
# File 'lib/algolia/api/search_client.rb', line 573

def browse(index_name, browse_params = nil, request_options = {})
  response = browse_with_http_info(index_name, browse_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::BrowseResponse")
end

#browse_objects(index_name, browse_params = Search::BrowseParamsObject.new, request_options = {}, &block) ⇒ Object

Helper: Iterate on the browse method of the client to allow aggregating objects of an index.

Parameters:

  • index_name (String) —

    the index_name to browse. (required)

  • browse_params (BrowseParamsObject) (defaults to: Search::BrowseParamsObject.new) —

    the browse_params to send along with the query, they will be forwarded to the browse method.

  • request_options (Hash) (defaults to: {}) —

    the requestOptions to send along with the query, they will be forwarded to the browse method.

  • block (Proc) —

    the block to execute on each object of the index.



3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
# File 'lib/algolia/api/search_client.rb', line 3839

def browse_objects(index_name, browse_params = Search::BrowseParamsObject.new, request_options = {}, &block)
  request_options = with_request_id(request_options)
  browse_params = api_client.object_to_hash(browse_params)

  browse_params[:hitsPerPage] = 1000 unless browse_params.key?(:hitsPerPage)

  hits = []
  loop do
    res = browse(index_name, browse_params, request_options)
    if block_given?
      res.hits.each do |hit|
        block.call(hit)
      end
    else
      hits.concat(res.hits)
    end

    browse_params[:cursor] = res.cursor
    break if browse_params[:cursor].nil?
  end

  hits unless block_given?
end

#browse_rules(index_name, search_rules_params = Search::SearchRulesParams.new, request_options = {}, &block) ⇒ Object

Helper: Iterate on the searchRules method of the client to allow aggregating rules of an index.

Parameters:

  • index_name (String) —

    the index_name to browse rules from. (required)

  • search_rules_params (SearchRulesParams) (defaults to: Search::SearchRulesParams.new) —

    the parameters to send along with the query, they will be forwarded to the searchRules method.

  • request_options (Hash) (defaults to: {}) —

    the requestOptions to send along with the query, they will be forwarded to the searchRules method.

  • block (Proc) —

    the block to execute on each rule of the index.



3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
# File 'lib/algolia/api/search_client.rb', line 3869

def browse_rules(index_name, search_rules_params = Search::SearchRulesParams.new, request_options = {}, &block)
  request_options = with_request_id(request_options)
  search_rules_params = api_client.object_to_hash(search_rules_params)

  search_rules_params[:page] ||= 0
  search_rules_params[:hitsPerPage] ||= 1000

  rules = []
  loop do
    res = search_rules(index_name, search_rules_params, request_options)
    if block_given?
      res.hits.each do |rule|
        block.call(rule)
      end
    else
      rules.concat(res.hits)
    end

    search_rules_params[:page] += 1
    break if res.hits.length < search_rules_params[:hitsPerPage]
  end

  rules unless block_given?
end

#browse_synonyms(index_name, search_synonyms_params = Search::SearchSynonymsParams.new, request_options = {}, &block) ⇒ Object

Helper: Iterate on the searchSynonyms method of the client to allow aggregating synonyms of an index.

Parameters:

  • index_name (String) —

    the index_name to browse synonyms from. (required)

  • search_synonyms_params (SearchSynonymsParams) (defaults to: Search::SearchSynonymsParams.new) —

    the parameters to send along with the query, they will be forwarded to the searchSynonyms method.

  • request_options (Hash) (defaults to: {}) —

    the requestOptions to send along with the query, they will be forwarded to the searchSynonyms method.

  • block (Proc) —

    the block to execute on each synonym of the index.



3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
# File 'lib/algolia/api/search_client.rb', line 3900

def browse_synonyms(
  index_name,
  search_synonyms_params = Search::SearchSynonymsParams.new,
  request_options = {},
  &block
)
  request_options = with_request_id(request_options)
  search_synonyms_params = api_client.object_to_hash(search_synonyms_params)

  search_synonyms_params[:page] ||= 0
  search_synonyms_params[:hitsPerPage] ||= 1000

  synonyms = []
  loop do
    res = search_synonyms(index_name, search_synonyms_params, request_options)
    if block_given?
      res.hits.each do |synonym|
        block.call(synonym)
      end
    else
      synonyms.concat(res.hits)
    end

    search_synonyms_params[:page] += 1
    break if res.hits.length < search_synonyms_params[:hitsPerPage]
  end

  synonyms unless block_given?
end

#browse_with_http_info(index_name, browse_params = nil, request_options = {}) ⇒ Http::Response

Retrieves records from an index, up to 1,000 per request. Searching returns hits (records augmented with highlighting and ranking details). Browsing returns matching records only. Use browse to export your indices. - The Analytics API doesn't collect data when using browse. - Records are ranked by attributes and custom ranking. - There's no ranking for typo tolerance, number of matched words, proximity, or geo distance. Browse requests automatically apply these settings: - advancedSyntax: false - attributesToHighlight: [] - attributesToSnippet: [] - distinct: false - enablePersonalization: false - enableRules: false - facets: [] - getRankingInfo: false - ignorePlurals: false - optionalFilters: [] - typoTolerance: true or false (min and strict evaluate to true) If you send these parameters with your browse requests, they're ignored.

Required API Key ACLs:

- browse

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • browse_params (BrowseParams) (defaults to: nil)
  • 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)

Returns:



536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
# File 'lib/algolia/api/search_client.rb', line 536

def browse_with_http_info(index_name, browse_params = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `browse`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `browse`."
  end

  path = "/1/indexes/{indexName}/browse".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(browse_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.browse",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#chunked_batch(index_name, objects, action = Action::ADD_OBJECT, wait_for_tasks = false, batch_size = 1000, request_options = {}, chunked_options = nil) ⇒ Array<BatchResponse>

Helper: Chunks the given objects list in subset of 1000 elements max in order to make it fit in batch requests.

Parameters:

  • index_name (String) —

    the index_name where the operation will be performed.

  • objects (Array) —

    The array of objects to store in the given Algolia index_name.

  • action (Action) (defaults to: Action::ADD_OBJECT) —

    The batch action to perform on the given array of objects, defaults to addObject.

  • wait_for_tasks (Boolean) (defaults to: false) —

    Whether or not we should wait until every batch tasks has been processed, this operation may slow the total execution time of this method but is more reliable.

  • batch_size (int) (defaults to: 1000) —

    The size of the chunk of objects. The number of batch calls will be equal to length(objects) / batchSize. Defaults to 1000.

  • 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)

Returns:

  • (Array<BatchResponse>)


4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
# File 'lib/algolia/api/search_client.rb', line 4101

def chunked_batch(
  index_name,
  objects,
  action = Action::ADD_OBJECT,
  wait_for_tasks = false,
  batch_size = 1000,
  request_options = {},
  chunked_options = nil
)
  request_options = with_request_id(request_options)
  opts = Algolia::ChunkedHelperOptions.resolve(chunked_options)
  responses = []
  objects.each_slice(batch_size) do |chunk|
    requests = chunk.map do |object|
      Search::BatchRequest.new(action: action, body: object)
    end

    responses.append(batch(index_name, Search::BatchWriteParams.new(requests: requests), request_options))
  end

  if wait_for_tasks
    responses.each do |response|
      wait_for_task(
        index_name,
        response.task_id,
        opts.max_retries,
        Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT,
        request_options
      )
    end
  end

  responses
end

#clear_objects(index_name, request_options = {}) ⇒ UpdatedAtResponse

Deletes only the records from an index while keeping settings, synonyms, and rules. This operation is resource-intensive and subject to indexing rate limits.

Required API Key ACLs:

- deleteIndex

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • 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)

Returns:

  • (UpdatedAtResponse)


621
622
623
624
# File 'lib/algolia/api/search_client.rb', line 621

def clear_objects(index_name, request_options = {})
  response = clear_objects_with_http_info(index_name, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
end

#clear_objects_with_http_info(index_name, request_options = {}) ⇒ Http::Response

Deletes only the records from an index while keeping settings, synonyms, and rules. This operation is resource-intensive and subject to indexing rate limits.

Required API Key ACLs:

- deleteIndex

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • 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)

Returns:



585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
# File 'lib/algolia/api/search_client.rb', line 585

def clear_objects_with_http_info(index_name, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `clear_objects`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `clear_objects`."
  end

  path = "/1/indexes/{indexName}/clear".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.clear_objects",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#clear_rules(index_name, forward_to_replicas = nil, request_options = {}) ⇒ UpdatedAtResponse

Deletes all rules from the index.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:

  • (UpdatedAtResponse)


672
673
674
675
# File 'lib/algolia/api/search_client.rb', line 672

def clear_rules(index_name, forward_to_replicas = nil, request_options = {})
  response = clear_rules_with_http_info(index_name, forward_to_replicas, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
end

#clear_rules_with_http_info(index_name, forward_to_replicas = nil, request_options = {}) ⇒ Http::Response

Deletes all rules from the index.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:



634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
# File 'lib/algolia/api/search_client.rb', line 634

def clear_rules_with_http_info(index_name, forward_to_replicas = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `clear_rules`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `clear_rules`."
  end

  path = "/1/indexes/{indexName}/rules/clear".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params[:forwardToReplicas] = forward_to_replicas unless forward_to_replicas.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.clear_rules",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#clear_synonyms(index_name, forward_to_replicas = nil, request_options = {}) ⇒ UpdatedAtResponse

Deletes all synonyms from the index.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:

  • (UpdatedAtResponse)


723
724
725
726
# File 'lib/algolia/api/search_client.rb', line 723

def clear_synonyms(index_name, forward_to_replicas = nil, request_options = {})
  response = clear_synonyms_with_http_info(index_name, forward_to_replicas, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
end

#clear_synonyms_with_http_info(index_name, forward_to_replicas = nil, request_options = {}) ⇒ Http::Response

Deletes all synonyms from the index.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:



685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
# File 'lib/algolia/api/search_client.rb', line 685

def clear_synonyms_with_http_info(index_name, forward_to_replicas = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `clear_synonyms`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `clear_synonyms`."
  end

  path = "/1/indexes/{indexName}/synonyms/clear".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params[:forwardToReplicas] = forward_to_replicas unless forward_to_replicas.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.clear_synonyms",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#custom_delete(path, parameters = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String) —

    Path of the endpoint, for example 1/newFeature. (required)

  • parameters (Hash<String, Object>) (defaults to: nil) —

    Query parameters to apply to the current query.

  • 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)

Returns:

  • (Object)


770
771
772
773
# File 'lib/algolia/api/search_client.rb', line 770

def custom_delete(path, parameters = nil, request_options = {})
  response = custom_delete_with_http_info(path, parameters, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#custom_delete_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String) —

    Path of the endpoint, for example 1/newFeature. (required)

  • parameters (Hash<String, Object>) (defaults to: nil) —

    Query parameters to apply to the current query.

  • 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)

Returns:



734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
# File 'lib/algolia/api/search_client.rb', line 734

def custom_delete_with_http_info(path, parameters = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
  end
  # verify the required parameter 'path' is not empty
  if @api_client.config.client_side_validation && path.empty?
    raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
  end

  path = "/{path}".sub("{" + "path" + "}", path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.custom_delete",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#custom_get(path, parameters = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String) —

    Path of the endpoint, for example 1/newFeature. (required)

  • parameters (Hash<String, Object>) (defaults to: nil) —

    Query parameters to apply to the current query.

  • 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)

Returns:

  • (Object)


817
818
819
820
# File 'lib/algolia/api/search_client.rb', line 817

def custom_get(path, parameters = nil, request_options = {})
  response = custom_get_with_http_info(path, parameters, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#custom_get_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String) —

    Path of the endpoint, for example 1/newFeature. (required)

  • parameters (Hash<String, Object>) (defaults to: nil) —

    Query parameters to apply to the current query.

  • 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)

Returns:



781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
# File 'lib/algolia/api/search_client.rb', line 781

def custom_get_with_http_info(path, parameters = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
  end
  # verify the required parameter 'path' is not empty
  if @api_client.config.client_side_validation && path.empty?
    raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
  end

  path = "/{path}".sub("{" + "path" + "}", path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.custom_get",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#custom_post(path, parameters = nil, body = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String) —

    Path of the endpoint, for example 1/newFeature. (required)

  • parameters (Hash<String, Object>) (defaults to: nil) —

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil) —

    Parameters to send with the custom request.

  • 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)

Returns:

  • (Object)


866
867
868
869
# File 'lib/algolia/api/search_client.rb', line 866

def custom_post(path, parameters = nil, body = nil, request_options = {})
  response = custom_post_with_http_info(path, parameters, body, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String) —

    Path of the endpoint, for example 1/newFeature. (required)

  • parameters (Hash<String, Object>) (defaults to: nil) —

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil) —

    Parameters to send with the custom request.

  • 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)

Returns:



829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
# File 'lib/algolia/api/search_client.rb', line 829

def custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
  end
  # verify the required parameter 'path' is not empty
  if @api_client.config.client_side_validation && path.empty?
    raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
  end

  path = "/{path}".sub("{" + "path" + "}", path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(body)

  new_options = request_options.merge(
    :operation => :"SearchClient.custom_post",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#custom_put(path, parameters = nil, body = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String) —

    Path of the endpoint, for example 1/newFeature. (required)

  • parameters (Hash<String, Object>) (defaults to: nil) —

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil) —

    Parameters to send with the custom request.

  • 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)

Returns:

  • (Object)


915
916
917
918
# File 'lib/algolia/api/search_client.rb', line 915

def custom_put(path, parameters = nil, body = nil, request_options = {})
  response = custom_put_with_http_info(path, parameters, body, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String) —

    Path of the endpoint, for example 1/newFeature. (required)

  • parameters (Hash<String, Object>) (defaults to: nil) —

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil) —

    Parameters to send with the custom request.

  • 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)

Returns:



878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
# File 'lib/algolia/api/search_client.rb', line 878

def custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
  end
  # verify the required parameter 'path' is not empty
  if @api_client.config.client_side_validation && path.empty?
    raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
  end

  path = "/{path}".sub("{" + "path" + "}", path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(body)

  new_options = request_options.merge(
    :operation => :"SearchClient.custom_put",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#delete_api_key(key, request_options = {}) ⇒ DeleteApiKeyResponse

Deletes the API key.

Required API Key ACLs:

- admin

Parameters:

  • key (String) —

    API key. (required)

  • 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)

Returns:

  • (DeleteApiKeyResponse)


963
964
965
966
# File 'lib/algolia/api/search_client.rb', line 963

def delete_api_key(key, request_options = {})
  response = delete_api_key_with_http_info(key, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::DeleteApiKeyResponse")
end

#delete_api_key_with_http_info(key, request_options = {}) ⇒ Http::Response

Deletes the API key.

Required API Key ACLs:

- admin

Parameters:

  • key (String) —

    API key. (required)

  • 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)

Returns:



927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
# File 'lib/algolia/api/search_client.rb', line 927

def delete_api_key_with_http_info(key, request_options = {})
  # verify the required parameter 'key' is set
  if @api_client.config.client_side_validation && key.nil?
    raise ArgumentError, "Parameter `key` is required when calling `delete_api_key`."
  end
  # verify the required parameter 'key' is not empty
  if @api_client.config.client_side_validation && key.empty?
    raise ArgumentError, "Parameter `key` is required when calling `delete_api_key`."
  end

  path = "/1/keys/{key}".sub("{" + "key" + "}", Transport.encode_uri(key.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.delete_api_key",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#delete_by(index_name, delete_by_params, request_options = {}) ⇒ UpdatedAtResponse

This operation doesn't accept empty filters. This operation is resource-intensive. Use it only if you can't get the object IDs of the records you want to delete. It's more efficient to get a list of object IDs with the browse operation, and then delete the records using the batch operation. This operation is subject to indexing rate limits.

Required API Key ACLs:

- deleteIndex

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • delete_by_params (DeleteByParams) —

    (required)

  • 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)

Returns:

  • (UpdatedAtResponse)


1017
1018
1019
1020
# File 'lib/algolia/api/search_client.rb', line 1017

def delete_by(index_name, delete_by_params, request_options = {})
  response = delete_by_with_http_info(index_name, delete_by_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
end

#delete_by_with_http_info(index_name, delete_by_params, request_options = {}) ⇒ Http::Response

This operation doesn't accept empty filters. This operation is resource-intensive. Use it only if you can't get the object IDs of the records you want to delete. It's more efficient to get a list of object IDs with the browse operation, and then delete the records using the batch operation. This operation is subject to indexing rate limits.

Required API Key ACLs:

- deleteIndex

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • delete_by_params (DeleteByParams) —

    (required)

  • 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)

Returns:



976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
# File 'lib/algolia/api/search_client.rb', line 976

def delete_by_with_http_info(index_name, delete_by_params, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `delete_by`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `delete_by`."
  end
  # verify the required parameter 'delete_by_params' is set
  if @api_client.config.client_side_validation && delete_by_params.nil?
    raise ArgumentError, "Parameter `delete_by_params` is required when calling `delete_by`."
  end

  path = "/1/indexes/{indexName}/deleteByQuery".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(delete_by_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.delete_by",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#delete_index(index_name, request_options = {}) ⇒ DeletedAtResponse

Deletes an index and all its settings. - Deleting an index doesn't delete its analytics data. - If you try to delete a non-existing index, the operation is ignored without warning. - If the index you want to delete has replica indices, the replicas become independent indices. - If the index you want to delete is a replica index, you must first unlink it from its primary index before you can delete it. For more information, see Delete replica indices.

Required API Key ACLs:

- deleteIndex

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • 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)

Returns:

  • (DeletedAtResponse)


1065
1066
1067
1068
# File 'lib/algolia/api/search_client.rb', line 1065

def delete_index(index_name, request_options = {})
  response = delete_index_with_http_info(index_name, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::DeletedAtResponse")
end

#delete_index_with_http_info(index_name, request_options = {}) ⇒ Http::Response

Deletes an index and all its settings. - Deleting an index doesn't delete its analytics data. - If you try to delete a non-existing index, the operation is ignored without warning. - If the index you want to delete has replica indices, the replicas become independent indices. - If the index you want to delete is a replica index, you must first unlink it from its primary index before you can delete it. For more information, see Delete replica indices.

Required API Key ACLs:

- deleteIndex

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • 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)

Returns:



1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
# File 'lib/algolia/api/search_client.rb', line 1029

def delete_index_with_http_info(index_name, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `delete_index`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `delete_index`."
  end

  path = "/1/indexes/{indexName}".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.delete_index",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#delete_object(index_name, algolia_object_id, request_options = {}) ⇒ DeletedAtResponse

Deletes a record by its object ID. To delete more than one record, use the batch operation. To delete records matching a query, use the deleteBy operation.

Required API Key ACLs:

- deleteObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique record identifier. (required)

  • 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)

Returns:

  • (DeletedAtResponse)


1126
1127
1128
1129
# File 'lib/algolia/api/search_client.rb', line 1126

def delete_object(index_name, algolia_object_id, request_options = {})
  response = delete_object_with_http_info(index_name, algolia_object_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::DeletedAtResponse")
end

#delete_object_with_http_info(index_name, algolia_object_id, request_options = {}) ⇒ Http::Response

Deletes a record by its object ID. To delete more than one record, use the batch operation. To delete records matching a query, use the deleteBy operation.

Required API Key ACLs:

- deleteObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique record identifier. (required)

  • 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)

Returns:



1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
# File 'lib/algolia/api/search_client.rb', line 1078

def delete_object_with_http_info(index_name, algolia_object_id, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `delete_object`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `delete_object`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_object`."
  end
  # verify the required parameter 'algolia_object_id' is not empty
  if @api_client.config.client_side_validation && algolia_object_id.empty?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_object`."
  end

  path = "/1/indexes/{indexName}/{objectID}".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s)).sub(
    "{" + "objectID" + "}",
    Transport.encode_uri(algolia_object_id.to_s)
  )
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.delete_object",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#delete_objects(index_name, object_ids, wait_for_tasks = false, batch_size = 1000, request_options = {}, chunked_options = nil) ⇒ BatchResponse

Helper: Deletes every records for the given objectIDs. The chunked_batch helper is used under the hood, which creates a batch requests with at most 1000 objectIDs in it.

Parameters:

  • index_name (String) —

    : The index_name to delete object_ids from.

  • object_ids (Array) —

    : The object_ids to delete.

  • wait_for_tasks (Boolean) (defaults to: false) —

    : Whether or not we should wait until every batch tasks has been processed, this operation may slow the total execution time of this method but is more reliable.

  • batch_size (int) (defaults to: 1000) —

    The size of the chunk of objects. The number of batch calls will be equal to length(objects) / batchSize. Defaults to 1000.

  • 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)

Returns:

  • (BatchResponse)


4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
# File 'lib/algolia/api/search_client.rb', line 4040

def delete_objects(
  index_name,
  object_ids,
  wait_for_tasks = false,
  batch_size = 1000,
  request_options = {},
  chunked_options = nil
)
  chunked_batch(
    index_name,
    object_ids.map { |id| {"objectID" => id} },
    Search::Action::DELETE_OBJECT,
    wait_for_tasks,
    batch_size,
    request_options,
    chunked_options
  )
end

#delete_rule(index_name, algolia_object_id, forward_to_replicas = nil, request_options = {}) ⇒ UpdatedAtResponse

Deletes a rule by its ID. To find the object ID for rules, use the search operation.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique identifier of a rule object. (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:

  • (UpdatedAtResponse)


1189
1190
1191
1192
# File 'lib/algolia/api/search_client.rb', line 1189

def delete_rule(index_name, algolia_object_id, forward_to_replicas = nil, request_options = {})
  response = delete_rule_with_http_info(index_name, algolia_object_id, forward_to_replicas, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
end

#delete_rule_with_http_info(index_name, algolia_object_id, forward_to_replicas = nil, request_options = {}) ⇒ Http::Response

Deletes a rule by its ID. To find the object ID for rules, use the search operation.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique identifier of a rule object. (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:



1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
# File 'lib/algolia/api/search_client.rb', line 1140

def delete_rule_with_http_info(index_name, algolia_object_id, forward_to_replicas = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `delete_rule`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `delete_rule`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_rule`."
  end
  # verify the required parameter 'algolia_object_id' is not empty
  if @api_client.config.client_side_validation && algolia_object_id.empty?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_rule`."
  end

  path = "/1/indexes/{indexName}/rules/{objectID}"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "objectID" + "}", Transport.encode_uri(algolia_object_id.to_s))
  query_params = {}
  query_params[:forwardToReplicas] = forward_to_replicas unless forward_to_replicas.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.delete_rule",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#delete_source(source, request_options = {}) ⇒ DeleteSourceResponse

Deletes a source from the list of allowed sources.

Required API Key ACLs:

- admin

Parameters:

  • source (String) —

    IP address range of the source. (required)

  • 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)

Returns:

  • (DeleteSourceResponse)


1237
1238
1239
1240
# File 'lib/algolia/api/search_client.rb', line 1237

def delete_source(source, request_options = {})
  response = delete_source_with_http_info(source, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::DeleteSourceResponse")
end

#delete_source_with_http_info(source, request_options = {}) ⇒ Http::Response

Deletes a source from the list of allowed sources.

Required API Key ACLs:

- admin

Parameters:

  • source (String) —

    IP address range of the source. (required)

  • 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)

Returns:



1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
# File 'lib/algolia/api/search_client.rb', line 1201

def delete_source_with_http_info(source, request_options = {})
  # verify the required parameter 'source' is set
  if @api_client.config.client_side_validation && source.nil?
    raise ArgumentError, "Parameter `source` is required when calling `delete_source`."
  end
  # verify the required parameter 'source' is not empty
  if @api_client.config.client_side_validation && source.empty?
    raise ArgumentError, "Parameter `source` is required when calling `delete_source`."
  end

  path = "/1/security/sources/{source}".sub("{" + "source" + "}", Transport.encode_uri(source.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.delete_source",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#delete_synonym(index_name, algolia_object_id, forward_to_replicas = nil, request_options = {}) ⇒ DeletedAtResponse

Deletes a synonym by its ID. To find the object IDs of your synonyms, use the search operation.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique identifier of a synonym object. (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:

  • (DeletedAtResponse)


1300
1301
1302
1303
# File 'lib/algolia/api/search_client.rb', line 1300

def delete_synonym(index_name, algolia_object_id, forward_to_replicas = nil, request_options = {})
  response = delete_synonym_with_http_info(index_name, algolia_object_id, forward_to_replicas, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::DeletedAtResponse")
end

#delete_synonym_with_http_info(index_name, algolia_object_id, forward_to_replicas = nil, request_options = {}) ⇒ Http::Response

Deletes a synonym by its ID. To find the object IDs of your synonyms, use the search operation.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique identifier of a synonym object. (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:



1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
# File 'lib/algolia/api/search_client.rb', line 1251

def delete_synonym_with_http_info(index_name, algolia_object_id, forward_to_replicas = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `delete_synonym`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `delete_synonym`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_synonym`."
  end
  # verify the required parameter 'algolia_object_id' is not empty
  if @api_client.config.client_side_validation && algolia_object_id.empty?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_synonym`."
  end

  path = "/1/indexes/{indexName}/synonyms/{objectID}"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "objectID" + "}", Transport.encode_uri(algolia_object_id.to_s))
  query_params = {}
  query_params[:forwardToReplicas] = forward_to_replicas unless forward_to_replicas.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.delete_synonym",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#generate_secured_api_key(parent_api_key, restrictions = {}) ⇒ String

Helper: Generates a secured API key based on the given parent_api_key and given restrictions.

Parameters:

  • parent_api_key (String) —

    Parent API key used the generate the secured key

  • restrictions (SecuredApiKeyRestrictions) (defaults to: {}) —

    Restrictions to apply on the secured key

Returns:

  • (String)


3966
3967
3968
# File 'lib/algolia/api/search_client.rb', line 3966

def generate_secured_api_key(parent_api_key, restrictions = {})
  self.class.generate_secured_api_key(parent_api_key, restrictions)
end

#get_api_key(key, request_options = {}) ⇒ GetApiKeyResponse

Gets the permissions and restrictions of an API key. When authenticating with the admin API key, you can request information for any of your application's keys. When authenticating with other API keys, you can only retrieve information for that key, with the description replaced by <redacted>.

Required API Key ACLs:

- search

Parameters:

  • key (String) —

    API key. (required)

  • 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)

Returns:

  • (GetApiKeyResponse)


1348
1349
1350
1351
# File 'lib/algolia/api/search_client.rb', line 1348

def get_api_key(key, request_options = {})
  response = get_api_key_with_http_info(key, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::GetApiKeyResponse")
end

#get_api_key_with_http_info(key, request_options = {}) ⇒ Http::Response

Gets the permissions and restrictions of an API key. When authenticating with the admin API key, you can request information for any of your application's keys. When authenticating with other API keys, you can only retrieve information for that key, with the description replaced by <redacted>.

Required API Key ACLs:

- search

Parameters:

  • key (String) —

    API key. (required)

  • 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)

Returns:



1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
# File 'lib/algolia/api/search_client.rb', line 1312

def get_api_key_with_http_info(key, request_options = {})
  # verify the required parameter 'key' is set
  if @api_client.config.client_side_validation && key.nil?
    raise ArgumentError, "Parameter `key` is required when calling `get_api_key`."
  end
  # verify the required parameter 'key' is not empty
  if @api_client.config.client_side_validation && key.empty?
    raise ArgumentError, "Parameter `key` is required when calling `get_api_key`."
  end

  path = "/1/keys/{key}".sub("{" + "key" + "}", Transport.encode_uri(key.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_api_key",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_app_task(task_id, request_options = {}) ⇒ GetTaskResponse

Checks the status of a given application task.

Required API Key ACLs:

- editSettings

Parameters:

  • task_id (Integer) —

    Unique task identifier. (required)

  • 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)

Returns:

  • (GetTaskResponse)


1392
1393
1394
1395
# File 'lib/algolia/api/search_client.rb', line 1392

def get_app_task(task_id, request_options = {})
  response = get_app_task_with_http_info(task_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::GetTaskResponse")
end

#get_app_task_with_http_info(task_id, request_options = {}) ⇒ Http::Response

Checks the status of a given application task.

Required API Key ACLs:

- editSettings

Parameters:

  • task_id (Integer) —

    Unique task identifier. (required)

  • 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)

Returns:



1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
# File 'lib/algolia/api/search_client.rb', line 1360

def get_app_task_with_http_info(task_id, request_options = {})
  # verify the required parameter 'task_id' is set
  if @api_client.config.client_side_validation && task_id.nil?
    raise ArgumentError, "Parameter `task_id` is required when calling `get_app_task`."
  end

  path = "/1/task/{taskID}".sub("{" + "taskID" + "}", Transport.encode_uri(task_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_app_task",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_dictionary_languages(request_options = {}) ⇒ Hash<String, Languages>

Lists supported languages with their supported dictionary types and number of custom entries.

Required API Key ACLs:

- settings

Parameters:

  • 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)

Returns:

  • (Hash<String, Languages>)


1429
1430
1431
1432
# File 'lib/algolia/api/search_client.rb', line 1429

def get_dictionary_languages(request_options = {})
  response = get_dictionary_languages_with_http_info(request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Hash<String, Languages>")
end

#get_dictionary_languages_with_http_info(request_options = {}) ⇒ Http::Response

Lists supported languages with their supported dictionary types and number of custom entries.

Required API Key ACLs:

- settings

Parameters:

  • 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)

Returns:



1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
# File 'lib/algolia/api/search_client.rb', line 1403

def get_dictionary_languages_with_http_info(request_options = {})
  path = "/1/dictionaries/*/languages"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_dictionary_languages",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_dictionary_settings(request_options = {}) ⇒ GetDictionarySettingsResponse

Retrieves the languages for which standard dictionary entries are turned off.

Required API Key ACLs:

- settings

Parameters:

  • 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)

Returns:

  • (GetDictionarySettingsResponse)


1466
1467
1468
1469
1470
1471
1472
# File 'lib/algolia/api/search_client.rb', line 1466

def get_dictionary_settings(request_options = {})
  response = get_dictionary_settings_with_http_info(request_options)
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Search::GetDictionarySettingsResponse"
  )
end

#get_dictionary_settings_with_http_info(request_options = {}) ⇒ Http::Response

Retrieves the languages for which standard dictionary entries are turned off.

Required API Key ACLs:

- settings

Parameters:

  • 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)

Returns:



1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
# File 'lib/algolia/api/search_client.rb', line 1440

def get_dictionary_settings_with_http_info(request_options = {})
  path = "/1/dictionaries/*/settings"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_dictionary_settings",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_logs(offset = nil, length = nil, index_name = nil, type = nil, request_options = {}) ⇒ GetLogsResponse

The request must be authenticated by an API key with the logs ACL. - Logs are held for the last seven days. - Up to 1,000 API requests per server are logged. - This request counts towards your operations quota but doesn't appear in the logs itself.

Required API Key ACLs:

- logs

Parameters:

  • offset (Integer) (defaults to: nil) —

    First log entry to retrieve. The most recent entries are listed first. (default to 0)

  • length (Integer) (defaults to: nil) —

    Maximum number of entries to retrieve. (default to 10)

  • index_name (String) (defaults to: nil) —

    Index for which to retrieve log entries. By default, log entries are retrieved for all indices.

  • type (LogType) (defaults to: nil) —

    Type of log entries to retrieve. By default, all log entries are retrieved. (default to 'all')

  • 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)

Returns:

  • (GetLogsResponse)


1518
1519
1520
1521
# File 'lib/algolia/api/search_client.rb', line 1518

def get_logs(offset = nil, length = nil, index_name = nil, type = nil, request_options = {})
  response = get_logs_with_http_info(offset, length, index_name, type, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::GetLogsResponse")
end

#get_logs_with_http_info(offset = nil, length = nil, index_name = nil, type = nil, request_options = {}) ⇒ Http::Response

The request must be authenticated by an API key with the logs ACL. - Logs are held for the last seven days. - Up to 1,000 API requests per server are logged. - This request counts towards your operations quota but doesn't appear in the logs itself.

Required API Key ACLs:

- logs

Parameters:

  • offset (Integer) (defaults to: nil) —

    First log entry to retrieve. The most recent entries are listed first. (default to 0)

  • length (Integer) (defaults to: nil) —

    Maximum number of entries to retrieve. (default to 10)

  • index_name (String) (defaults to: nil) —

    Index for which to retrieve log entries. By default, log entries are retrieved for all indices.

  • type (LogType) (defaults to: nil) —

    Type of log entries to retrieve. By default, all log entries are retrieved. (default to 'all')

  • 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)

Returns:



1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
# File 'lib/algolia/api/search_client.rb', line 1484

def get_logs_with_http_info(offset = nil, length = nil, index_name = nil, type = nil, request_options = {})
  path = "/1/logs"
  query_params = {}
  query_params[:offset] = offset unless offset.nil?
  query_params[:length] = length unless length.nil?
  query_params[:indexName] = index_name unless index_name.nil?
  query_params[:type] = type unless type.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_logs",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_object(index_name, algolia_object_id, attributes_to_retrieve = nil, request_options = {}) ⇒ Object

Retrieves one record by its object ID. To retrieve more than one record, use the objects operation.

Required API Key ACLs:

- search

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique record identifier. (required)

  • attributes_to_retrieve (Array<String>) (defaults to: nil) —

    Attributes to include with the records in the response. This is useful to reduce the size of the API response. By default, all retrievable attributes are returned. objectID is always retrieved. Attributes included in unretrievableAttributes won't be retrieved unless the request is authenticated with the admin API key.

  • 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)

Returns:

  • (Object)


1585
1586
1587
1588
# File 'lib/algolia/api/search_client.rb', line 1585

def get_object(index_name, algolia_object_id, attributes_to_retrieve = nil, request_options = {})
  response = get_object_with_http_info(index_name, algolia_object_id, attributes_to_retrieve, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#get_object_with_http_info(index_name, algolia_object_id, attributes_to_retrieve = nil, request_options = {}) ⇒ Http::Response

Retrieves one record by its object ID. To retrieve more than one record, use the objects operation.

Required API Key ACLs:

- search

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique record identifier. (required)

  • attributes_to_retrieve (Array<String>) (defaults to: nil) —

    Attributes to include with the records in the response. This is useful to reduce the size of the API response. By default, all retrievable attributes are returned. objectID is always retrieved. Attributes included in unretrievableAttributes won't be retrieved unless the request is authenticated with the admin API key.

  • 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)

Returns:



1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
# File 'lib/algolia/api/search_client.rb', line 1532

def get_object_with_http_info(index_name, algolia_object_id, attributes_to_retrieve = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `get_object`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `get_object`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_object`."
  end
  # verify the required parameter 'algolia_object_id' is not empty
  if @api_client.config.client_side_validation && algolia_object_id.empty?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_object`."
  end

  path = "/1/indexes/{indexName}/{objectID}".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s)).sub(
    "{" + "objectID" + "}",
    Transport.encode_uri(algolia_object_id.to_s)
  )
  query_params = {}
  unless attributes_to_retrieve.nil?
    query_params[:attributesToRetrieve] = @api_client.build_collection_param(attributes_to_retrieve, :multi)
  end

  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_object",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_objects(get_objects_params, request_options = {}) ⇒ GetObjectsResponse

Retrieves one or more records, potentially from different indices. Records are returned in the same order as the requests.

Required API Key ACLs:

- search

Parameters:

  • get_objects_params (GetObjectsParams) —

    Request object. (required)

  • 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)

Returns:

  • (GetObjectsResponse)


1629
1630
1631
1632
# File 'lib/algolia/api/search_client.rb', line 1629

def get_objects(get_objects_params, request_options = {})
  response = get_objects_with_http_info(get_objects_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::GetObjectsResponse")
end

#get_objects_with_http_info(get_objects_params, request_options = {}) ⇒ Http::Response

Retrieves one or more records, potentially from different indices. Records are returned in the same order as the requests.

Required API Key ACLs:

- search

Parameters:

  • get_objects_params (GetObjectsParams) —

    Request object. (required)

  • 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)

Returns:



1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
# File 'lib/algolia/api/search_client.rb', line 1597

def get_objects_with_http_info(get_objects_params, request_options = {})
  # verify the required parameter 'get_objects_params' is set
  if @api_client.config.client_side_validation && get_objects_params.nil?
    raise ArgumentError, "Parameter `get_objects_params` is required when calling `get_objects`."
  end

  path = "/1/indexes/*/objects"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(get_objects_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.get_objects",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#get_rule(index_name, algolia_object_id, request_options = {}) ⇒ Rule

Retrieves a rule by its ID. To find the object ID of rules, use the search operation.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique identifier of a rule object. (required)

  • 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)

Returns:

  • (Rule)


1689
1690
1691
1692
# File 'lib/algolia/api/search_client.rb', line 1689

def get_rule(index_name, algolia_object_id, request_options = {})
  response = get_rule_with_http_info(index_name, algolia_object_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::Rule")
end

#get_rule_with_http_info(index_name, algolia_object_id, request_options = {}) ⇒ Http::Response

Retrieves a rule by its ID. To find the object ID of rules, use the search operation.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique identifier of a rule object. (required)

  • 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)

Returns:



1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
# File 'lib/algolia/api/search_client.rb', line 1642

def get_rule_with_http_info(index_name, algolia_object_id, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `get_rule`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `get_rule`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_rule`."
  end
  # verify the required parameter 'algolia_object_id' is not empty
  if @api_client.config.client_side_validation && algolia_object_id.empty?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_rule`."
  end

  path = "/1/indexes/{indexName}/rules/{objectID}"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "objectID" + "}", Transport.encode_uri(algolia_object_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_rule",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_secured_api_key_remaining_validity(secured_api_key) ⇒ Integer

Helper: Retrieves the remaining validity of the previous generated secured_api_key, the validUntil parameter must have been provided.

Parameters:

  • secured_api_key (String)

Returns:

  • (Integer)


3997
3998
3999
# File 'lib/algolia/api/search_client.rb', line 3997

def get_secured_api_key_remaining_validity(secured_api_key)
  self.class.get_secured_api_key_remaining_validity(secured_api_key)
end

#get_settings(index_name, get_version = nil, request_options = {}) ⇒ SettingsResponse

Retrieves an object with non-null index settings.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • get_version (Integer) (defaults to: nil) —

    When set to 2, the endpoint will not include synonyms in the response. This parameter is here for backward compatibility. (default to 1)

  • 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)

Returns:

  • (SettingsResponse)


1740
1741
1742
1743
# File 'lib/algolia/api/search_client.rb', line 1740

def get_settings(index_name, get_version = nil, request_options = {})
  response = get_settings_with_http_info(index_name, get_version, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::SettingsResponse")
end

#get_settings_with_http_info(index_name, get_version = nil, request_options = {}) ⇒ Http::Response

Retrieves an object with non-null index settings.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • get_version (Integer) (defaults to: nil) —

    When set to 2, the endpoint will not include synonyms in the response. This parameter is here for backward compatibility. (default to 1)

  • 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)

Returns:



1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
# File 'lib/algolia/api/search_client.rb', line 1702

def get_settings_with_http_info(index_name, get_version = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `get_settings`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `get_settings`."
  end

  path = "/1/indexes/{indexName}/settings".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params[:getVersion] = get_version unless get_version.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_settings",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_sources(request_options = {}) ⇒ Array<Source>

Retrieves all allowed IP addresses with access to your application.

Required API Key ACLs:

- admin

Parameters:

  • 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)

Returns:

  • (Array<Source>)


1777
1778
1779
1780
# File 'lib/algolia/api/search_client.rb', line 1777

def get_sources(request_options = {})
  response = get_sources_with_http_info(request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Array<Search::Source>")
end

#get_sources_with_http_info(request_options = {}) ⇒ Http::Response

Retrieves all allowed IP addresses with access to your application.

Required API Key ACLs:

- admin

Parameters:

  • 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)

Returns:



1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
# File 'lib/algolia/api/search_client.rb', line 1751

def get_sources_with_http_info(request_options = {})
  path = "/1/security/sources"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_sources",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_synonym(index_name, algolia_object_id, request_options = {}) ⇒ SynonymHit

Retrieves a synonym by its ID. To find the object IDs for your synonyms, use the search operation.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique identifier of a synonym object. (required)

  • 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)

Returns:

  • (SynonymHit)


1837
1838
1839
1840
# File 'lib/algolia/api/search_client.rb', line 1837

def get_synonym(index_name, algolia_object_id, request_options = {})
  response = get_synonym_with_http_info(index_name, algolia_object_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::SynonymHit")
end

#get_synonym_with_http_info(index_name, algolia_object_id, request_options = {}) ⇒ Http::Response

Retrieves a synonym by its ID. To find the object IDs for your synonyms, use the search operation.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique identifier of a synonym object. (required)

  • 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)

Returns:



1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
# File 'lib/algolia/api/search_client.rb', line 1790

def get_synonym_with_http_info(index_name, algolia_object_id, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `get_synonym`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `get_synonym`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_synonym`."
  end
  # verify the required parameter 'algolia_object_id' is not empty
  if @api_client.config.client_side_validation && algolia_object_id.empty?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_synonym`."
  end

  path = "/1/indexes/{indexName}/synonyms/{objectID}"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "objectID" + "}", Transport.encode_uri(algolia_object_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_synonym",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_task(index_name, task_id, request_options = {}) ⇒ GetTaskResponse

Checks the status of a given task. Indexing tasks are asynchronous. When you add, update, or delete records or indices, a task is created on a queue and completed depending on the load on the server. The indexing tasks' responses include a task ID that you can use to check the status.

Required API Key ACLs:

- addObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • task_id (Integer) —

    Unique task identifier. (required)

  • 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)

Returns:

  • (GetTaskResponse)


1893
1894
1895
1896
# File 'lib/algolia/api/search_client.rb', line 1893

def get_task(index_name, task_id, request_options = {})
  response = get_task_with_http_info(index_name, task_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::GetTaskResponse")
end

#get_task_with_http_info(index_name, task_id, request_options = {}) ⇒ Http::Response

Checks the status of a given task. Indexing tasks are asynchronous. When you add, update, or delete records or indices, a task is created on a queue and completed depending on the load on the server. The indexing tasks' responses include a task ID that you can use to check the status.

Required API Key ACLs:

- addObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • task_id (Integer) —

    Unique task identifier. (required)

  • 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)

Returns:



1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
# File 'lib/algolia/api/search_client.rb', line 1850

def get_task_with_http_info(index_name, task_id, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `get_task`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `get_task`."
  end
  # verify the required parameter 'task_id' is set
  if @api_client.config.client_side_validation && task_id.nil?
    raise ArgumentError, "Parameter `task_id` is required when calling `get_task`."
  end

  path = "/1/indexes/{indexName}/task/{taskID}"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "taskID" + "}", Transport.encode_uri(task_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_task",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_top_user_ids(request_options = {}) ⇒ GetTopUserIdsResponse

Get the IDs of the 10 users with the highest number of records per cluster. Since it can take a few seconds to get the data from the different clusters, the response isn't real-time.

Required API Key ACLs:

- admin

Parameters:

  • 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)

Returns:

  • (GetTopUserIdsResponse)


1931
1932
1933
1934
# File 'lib/algolia/api/search_client.rb', line 1931

def get_top_user_ids(request_options = {})
  response = get_top_user_ids_with_http_info(request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::GetTopUserIdsResponse")
end

#get_top_user_ids_with_http_info(request_options = {}) ⇒ Http::Response

Get the IDs of the 10 users with the highest number of records per cluster. Since it can take a few seconds to get the data from the different clusters, the response isn't real-time.

Required API Key ACLs:

- admin

THIS OPERATION IS DEPRECATED

Parameters:

  • 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)

Returns:



1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
# File 'lib/algolia/api/search_client.rb', line 1905

def get_top_user_ids_with_http_info(request_options = {})
  path = "/1/clusters/mapping/top"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_top_user_ids",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_user_id(user_id, request_options = {}) ⇒ UserId

Returns the user ID data stored in the mapping. Since it can take a few seconds to get the data from the different clusters, the response isn't real-time.

Required API Key ACLs:

- admin

Parameters:

  • user_id (String) —

    Unique identifier of the user who makes the search request. (required)

  • 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)

Returns:

  • (UserId)


1980
1981
1982
1983
# File 'lib/algolia/api/search_client.rb', line 1980

def get_user_id(user_id, request_options = {})
  response = get_user_id_with_http_info(user_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UserId")
end

#get_user_id_with_http_info(user_id, request_options = {}) ⇒ Http::Response

Returns the user ID data stored in the mapping. Since it can take a few seconds to get the data from the different clusters, the response isn't real-time.

Required API Key ACLs:

- admin

THIS OPERATION IS DEPRECATED

Parameters:

  • user_id (String) —

    Unique identifier of the user who makes the search request. (required)

  • 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)

Returns:



1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
# File 'lib/algolia/api/search_client.rb', line 1944

def get_user_id_with_http_info(user_id, request_options = {})
  # verify the required parameter 'user_id' is set
  if @api_client.config.client_side_validation && user_id.nil?
    raise ArgumentError, "Parameter `user_id` is required when calling `get_user_id`."
  end
  # verify the required parameter 'user_id' is not empty
  if @api_client.config.client_side_validation && user_id.empty?
    raise ArgumentError, "Parameter `user_id` is required when calling `get_user_id`."
  end

  path = "/1/clusters/mapping/{userID}".sub("{" + "userID" + "}", Transport.encode_uri(user_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.get_user_id",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#has_pending_mappings(get_clusters = nil, request_options = {}) ⇒ HasPendingMappingsResponse

To determine when the time-consuming process of creating a large batch of users or migrating users from one cluster to another is complete, this operation retrieves the status of the process.

Required API Key ACLs:

- admin

Parameters:

  • get_clusters (Boolean) (defaults to: nil) —

    Whether to include the cluster's pending mapping state in the response.

  • 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)

Returns:

  • (HasPendingMappingsResponse)


2021
2022
2023
2024
2025
2026
2027
# File 'lib/algolia/api/search_client.rb', line 2021

def has_pending_mappings(get_clusters = nil, request_options = {})
  response = has_pending_mappings_with_http_info(get_clusters, request_options)
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Search::HasPendingMappingsResponse"
  )
end

#has_pending_mappings_with_http_info(get_clusters = nil, request_options = {}) ⇒ Http::Response

To determine when the time-consuming process of creating a large batch of users or migrating users from one cluster to another is complete, this operation retrieves the status of the process.

Required API Key ACLs:

- admin

THIS OPERATION IS DEPRECATED

Parameters:

  • get_clusters (Boolean) (defaults to: nil) —

    Whether to include the cluster's pending mapping state in the response.

  • 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)

Returns:



1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
# File 'lib/algolia/api/search_client.rb', line 1993

def has_pending_mappings_with_http_info(get_clusters = nil, request_options = {})
  path = "/1/clusters/mapping/pending"
  query_params = {}
  query_params[:getClusters] = get_clusters unless get_clusters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.has_pending_mappings",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#index_exists?(index_name) ⇒ Boolean

Returns:

  • (Boolean)


4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
# File 'lib/algolia/api/search_client.rb', line 4251

def index_exists?(index_name)
  begin
    get_settings(index_name)
  rescue Exception => e
    if e.is_a?(AlgoliaHttpError)
      return false if e.code == 404

      raise e
    end
  end

  true
end

#list_api_keys(request_options = {}) ⇒ ListApiKeysResponse

Lists all API keys associated with your Algolia application, including their permissions and restrictions.

Required API Key ACLs:

- admin

Parameters:

  • 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)

Returns:

  • (ListApiKeysResponse)


2061
2062
2063
2064
# File 'lib/algolia/api/search_client.rb', line 2061

def list_api_keys(request_options = {})
  response = list_api_keys_with_http_info(request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::ListApiKeysResponse")
end

#list_api_keys_with_http_info(request_options = {}) ⇒ Http::Response

Lists all API keys associated with your Algolia application, including their permissions and restrictions.

Required API Key ACLs:

- admin

Parameters:

  • 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)

Returns:



2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
# File 'lib/algolia/api/search_client.rb', line 2035

def list_api_keys_with_http_info(request_options = {})
  path = "/1/keys"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.list_api_keys",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#list_clusters(request_options = {}) ⇒ ListClustersResponse

Lists the available clusters in a multi-cluster setup.

Required API Key ACLs:

- admin

Parameters:

  • 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)

Returns:

  • (ListClustersResponse)


2099
2100
2101
2102
# File 'lib/algolia/api/search_client.rb', line 2099

def list_clusters(request_options = {})
  response = list_clusters_with_http_info(request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::ListClustersResponse")
end

#list_clusters_with_http_info(request_options = {}) ⇒ Http::Response

Lists the available clusters in a multi-cluster setup.

Required API Key ACLs:

- admin

THIS OPERATION IS DEPRECATED

Parameters:

  • 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)

Returns:



2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
# File 'lib/algolia/api/search_client.rb', line 2073

def list_clusters_with_http_info(request_options = {})
  path = "/1/clusters"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.list_clusters",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#list_indices(page = nil, hits_per_page = nil, request_options = {}) ⇒ ListIndicesResponse

Lists all indices in the current Algolia application. The request follows any index restrictions of the API key you use to make the request.

Required API Key ACLs:

- listIndexes

Parameters:

  • page (Integer) (defaults to: nil) —

    Requested page of the API response. If null, the API response is not paginated.

  • hits_per_page (Integer) (defaults to: nil) —

    Number of hits per page. (default to 100)

  • 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)

Returns:

  • (ListIndicesResponse)


2142
2143
2144
2145
# File 'lib/algolia/api/search_client.rb', line 2142

def list_indices(page = nil, hits_per_page = nil, request_options = {})
  response = list_indices_with_http_info(page, hits_per_page, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::ListIndicesResponse")
end

#list_indices_with_http_info(page = nil, hits_per_page = nil, request_options = {}) ⇒ Http::Response

Lists all indices in the current Algolia application. The request follows any index restrictions of the API key you use to make the request.

Required API Key ACLs:

- listIndexes

Parameters:

  • page (Integer) (defaults to: nil) —

    Requested page of the API response. If null, the API response is not paginated.

  • hits_per_page (Integer) (defaults to: nil) —

    Number of hits per page. (default to 100)

  • 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)

Returns:



2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
# File 'lib/algolia/api/search_client.rb', line 2112

def list_indices_with_http_info(page = nil, hits_per_page = nil, request_options = {})
  path = "/1/indexes"
  query_params = {}
  query_params[:page] = page unless page.nil?
  query_params[:hitsPerPage] = hits_per_page unless hits_per_page.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.list_indices",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#list_user_ids(page = nil, hits_per_page = nil, request_options = {}) ⇒ ListUserIdsResponse

Lists the userIDs assigned to a multi-cluster application. Since it can take a few seconds to get the data from the different clusters, the response isn't real-time.

Required API Key ACLs:

- admin

Parameters:

  • page (Integer) (defaults to: nil) —

    Requested page of the API response. If null, the API response is not paginated.

  • hits_per_page (Integer) (defaults to: nil) —

    Number of hits per page. (default to 100)

  • 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)

Returns:

  • (ListUserIdsResponse)


2186
2187
2188
2189
# File 'lib/algolia/api/search_client.rb', line 2186

def list_user_ids(page = nil, hits_per_page = nil, request_options = {})
  response = list_user_ids_with_http_info(page, hits_per_page, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::ListUserIdsResponse")
end

#list_user_ids_with_http_info(page = nil, hits_per_page = nil, request_options = {}) ⇒ Http::Response

Lists the userIDs assigned to a multi-cluster application. Since it can take a few seconds to get the data from the different clusters, the response isn't real-time.

Required API Key ACLs:

- admin

THIS OPERATION IS DEPRECATED

Parameters:

  • page (Integer) (defaults to: nil) —

    Requested page of the API response. If null, the API response is not paginated.

  • hits_per_page (Integer) (defaults to: nil) —

    Number of hits per page. (default to 100)

  • 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)

Returns:



2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
# File 'lib/algolia/api/search_client.rb', line 2156

def list_user_ids_with_http_info(page = nil, hits_per_page = nil, request_options = {})
  path = "/1/clusters/mapping"
  query_params = {}
  query_params[:page] = page unless page.nil?
  query_params[:hitsPerPage] = hits_per_page unless hits_per_page.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.list_user_ids",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#multiple_batch(batch_params, request_options = {}) ⇒ MultipleBatchResponse

Adds, updates, or deletes records in multiple indices with a single API request. - Actions are applied in the order they are specified. - Actions are equivalent to the individual API requests of the same name. This operation is subject to indexing rate limits.

Required API Key ACLs:

- addObject

Parameters:

  • batch_params (BatchParams) —

    (required)

  • 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)

Returns:

  • (MultipleBatchResponse)


2230
2231
2232
2233
# File 'lib/algolia/api/search_client.rb', line 2230

def multiple_batch(batch_params, request_options = {})
  response = multiple_batch_with_http_info(batch_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::MultipleBatchResponse")
end

#multiple_batch_with_http_info(batch_params, request_options = {}) ⇒ Http::Response

Adds, updates, or deletes records in multiple indices with a single API request. - Actions are applied in the order they are specified. - Actions are equivalent to the individual API requests of the same name. This operation is subject to indexing rate limits.

Required API Key ACLs:

- addObject

Parameters:

  • batch_params (BatchParams) —

    (required)

  • 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)

Returns:



2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
# File 'lib/algolia/api/search_client.rb', line 2198

def multiple_batch_with_http_info(batch_params, request_options = {})
  # verify the required parameter 'batch_params' is set
  if @api_client.config.client_side_validation && batch_params.nil?
    raise ArgumentError, "Parameter `batch_params` is required when calling `multiple_batch`."
  end

  path = "/1/indexes/*/batch"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(batch_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.multiple_batch",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#operation_index(index_name, operation_index_params, request_options = {}) ⇒ UpdatedAtResponse

Copies or moves (renames) an index within the same Algolia application. Notes: - Existing destination indices are overwritten, except for their analytics data. - If the destination index doesn't exist yet, it's created. - This operation is resource-intensive. Copy - If the source index doesn't exist, copying creates a new index with 0 records and default settings. - API keys from the source index are merged with the existing keys in the destination index. - You can't copy the enableReRanking, mode, and replicas settings. - You can't copy to a destination index that already has replicas. - Be aware of the size limits. - For more information, see Copy indices. Move - If the source index doesn't exist, moving is ignored without returning an error. - When moving an index, the analytics data keeps its original name, and a new set of analytics data is started for the new name. To access the original analytics in the dashboard, create an index with the original name. - If the destination index has replicas, moving will overwrite the existing index and copy the data to the replica indices. - For more information, see Move indices. This operation is subject to indexing rate limits.

Required API Key ACLs:

- addObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • operation_index_params (OperationIndexParams) —

    (required)

  • 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)

Returns:

  • (UpdatedAtResponse)


2284
2285
2286
2287
# File 'lib/algolia/api/search_client.rb', line 2284

def operation_index(index_name, operation_index_params, request_options = {})
  response = operation_index_with_http_info(index_name, operation_index_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
end

#operation_index_with_http_info(index_name, operation_index_params, request_options = {}) ⇒ Http::Response

Copies or moves (renames) an index within the same Algolia application. Notes: - Existing destination indices are overwritten, except for their analytics data. - If the destination index doesn't exist yet, it's created. - This operation is resource-intensive. Copy - If the source index doesn't exist, copying creates a new index with 0 records and default settings. - API keys from the source index are merged with the existing keys in the destination index. - You can't copy the enableReRanking, mode, and replicas settings. - You can't copy to a destination index that already has replicas. - Be aware of the size limits. - For more information, see Copy indices. Move - If the source index doesn't exist, moving is ignored without returning an error. - When moving an index, the analytics data keeps its original name, and a new set of analytics data is started for the new name. To access the original analytics in the dashboard, create an index with the original name. - If the destination index has replicas, moving will overwrite the existing index and copy the data to the replica indices. - For more information, see Move indices. This operation is subject to indexing rate limits.

Required API Key ACLs:

- addObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • operation_index_params (OperationIndexParams) —

    (required)

  • 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)

Returns:



2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
# File 'lib/algolia/api/search_client.rb', line 2243

def operation_index_with_http_info(index_name, operation_index_params, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `operation_index`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `operation_index`."
  end
  # verify the required parameter 'operation_index_params' is set
  if @api_client.config.client_side_validation && operation_index_params.nil?
    raise ArgumentError, "Parameter `operation_index_params` is required when calling `operation_index`."
  end

  path = "/1/indexes/{indexName}/operation".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(operation_index_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.operation_index",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#partial_update_object(index_name, algolia_object_id, attributes_to_update, create_if_not_exists = nil, request_options = {}) ⇒ UpdatedAtWithObjectIdResponse

Adds new attributes to a record, or updates existing ones. - If a record with the specified object ID doesn't exist, a new record is added to the index if createIfNotExists is true. - If the index doesn't exist yet, this method creates a new index. - Use first-level attributes only. Nested attributes aren't supported. If you specify a nested attribute, this operation replaces its first-level ancestor. To update attributes without replacing the full record, use these built-in operations. These operations are useful when the initial data isn't available. - Increment: increment a numeric attribute. - Decrement: decrement a numeric attribute. - Add: append a number or string element to an array attribute. - Remove: remove all matching number or string elements from an array attribute made of numbers or strings. - AddUnique: add a number or string element to an array attribute made of numbers or strings only if it's not already present. - IncrementFrom: increment a numeric integer attribute only if the provided value matches the current value. Otherwise, the update is ignored. Example: If you pass an IncrementFrom value of 2 for the version attribute but the current value is 1, the API ignores the update. If the object doesn't exist, the API only creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if the provided value is greater than the current value. Otherwise, the update is ignored. Example: If you pass an IncrementSet value of 2 for the version attribute and the current value is 1, the API updates the object. If the object doesn't exist yet, the API only creates it if you pass an IncrementSet value greater than 0. Specify an operation by providing an object with the attribute to update as the key and its value as an object with these properties: - _operation: the operation to apply on the attribute. - value: the right-hand side argument to the operation, for example, increment or decrement step, or a value to add or remove. When updating multiple attributes or using multiple operations targeting the same record, use a single partial update for faster processing. This operation is subject to indexing rate limits.

Required API Key ACLs:

- addObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique record identifier. (required)

  • attributes_to_update (Object) —

    Attributes with their values. (required)

  • create_if_not_exists (Boolean) (defaults to: nil) —

    Whether to create a new record if it doesn't exist. (default to true)

  • 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)

Returns:

  • (UpdatedAtWithObjectIdResponse)


2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
# File 'lib/algolia/api/search_client.rb', line 2359

def partial_update_object(
  index_name,
  algolia_object_id,
  attributes_to_update,
  create_if_not_exists = nil,
  request_options = {}
)
  response = partial_update_object_with_http_info(
    index_name,
    algolia_object_id,
    attributes_to_update,
    create_if_not_exists,
    request_options
  )
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Search::UpdatedAtWithObjectIdResponse"
  )
end

#partial_update_object_with_http_info(index_name, algolia_object_id, attributes_to_update, create_if_not_exists = nil, request_options = {}) ⇒ Http::Response

Adds new attributes to a record, or updates existing ones. - If a record with the specified object ID doesn't exist, a new record is added to the index if createIfNotExists is true. - If the index doesn't exist yet, this method creates a new index. - Use first-level attributes only. Nested attributes aren't supported. If you specify a nested attribute, this operation replaces its first-level ancestor. To update attributes without replacing the full record, use these built-in operations. These operations are useful when the initial data isn't available. - Increment: increment a numeric attribute. - Decrement: decrement a numeric attribute. - Add: append a number or string element to an array attribute. - Remove: remove all matching number or string elements from an array attribute made of numbers or strings. - AddUnique: add a number or string element to an array attribute made of numbers or strings only if it's not already present. - IncrementFrom: increment a numeric integer attribute only if the provided value matches the current value. Otherwise, the update is ignored. Example: If you pass an IncrementFrom value of 2 for the version attribute but the current value is 1, the API ignores the update. If the object doesn't exist, the API only creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if the provided value is greater than the current value. Otherwise, the update is ignored. Example: If you pass an IncrementSet value of 2 for the version attribute and the current value is 1, the API updates the object. If the object doesn't exist yet, the API only creates it if you pass an IncrementSet value greater than 0. Specify an operation by providing an object with the attribute to update as the key and its value as an object with these properties: - _operation: the operation to apply on the attribute. - value: the right-hand side argument to the operation, for example, increment or decrement step, or a value to add or remove. When updating multiple attributes or using multiple operations targeting the same record, use a single partial update for faster processing. This operation is subject to indexing rate limits.

Required API Key ACLs:

- addObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique record identifier. (required)

  • attributes_to_update (Object) —

    Attributes with their values. (required)

  • create_if_not_exists (Boolean) (defaults to: nil) —

    Whether to create a new record if it doesn't exist. (default to true)

  • 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)

Returns:



2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
# File 'lib/algolia/api/search_client.rb', line 2299

def partial_update_object_with_http_info(
  index_name,
  algolia_object_id,
  attributes_to_update,
  create_if_not_exists = nil,
  request_options = {}
)
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `partial_update_object`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `partial_update_object`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `partial_update_object`."
  end
  # verify the required parameter 'algolia_object_id' is not empty
  if @api_client.config.client_side_validation && algolia_object_id.empty?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `partial_update_object`."
  end
  # verify the required parameter 'attributes_to_update' is set
  if @api_client.config.client_side_validation && attributes_to_update.nil?
    raise ArgumentError, "Parameter `attributes_to_update` is required when calling `partial_update_object`."
  end

  path = "/1/indexes/{indexName}/{objectID}/partial"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "objectID" + "}", Transport.encode_uri(algolia_object_id.to_s))
  query_params = {}
  query_params[:createIfNotExists] = create_if_not_exists unless create_if_not_exists.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(attributes_to_update)

  new_options = request_options.merge(
    :operation => :"SearchClient.partial_update_object",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#partial_update_objects(index_name, objects, create_if_not_exists, wait_for_tasks = false, batch_size = 1000, request_options = {}, chunked_options = nil) ⇒ BatchResponse

Helper: Replaces object content of all the given objects according to their respective object_id field. The chunkedBatch helper is used under the hood, which creates a batch requests with at most 1000 objects in it.

Parameters:

  • index_name (String) —

    : The index_name to delete object_ids from.

  • objects (Array) —

    : The objects to partially update.

  • create_if_not_exists (Boolean) —

    : To be provided if non-existing objects are passed, otherwise, the call will fail.

  • wait_for_tasks (Boolean) (defaults to: false) —

    Whether or not we should wait until every batch tasks has been processed, this operation may slow the total execution time of this method but is more reliable.

  • batch_size (int) (defaults to: 1000) —

    The size of the chunk of objects. The number of batch calls will be equal to length(objects) / batchSize. Defaults to 1000.

  • 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)

Returns:

  • (BatchResponse)


4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
# File 'lib/algolia/api/search_client.rb', line 4070

def partial_update_objects(
  index_name,
  objects,
  create_if_not_exists,
  wait_for_tasks = false,
  batch_size = 1000,
  request_options = {},
  chunked_options = nil
)
  chunked_batch(
    index_name,
    objects,
    create_if_not_exists ? Search::Action::PARTIAL_UPDATE_OBJECT : Search::Action::PARTIAL_UPDATE_OBJECT_NO_CREATE,
    wait_for_tasks,
    batch_size,
    request_options,
    chunked_options
  )
end

#partial_update_objects_with_transformation(index_name, objects, create_if_not_exists = false, wait_for_tasks = false, batch_size = 1000, request_options = {}, chunked_options = nil) ⇒ Array<Ingestion::WatchResponse>

Helper: Similar to the partial_update_objects method but requires a Push connector to be created first, in order to transform records before indexing them to Algolia. set_transformation_options must have been called, or the client created via SearchClient.with_transformation.

Parameters:

  • index_name (String) —

    the index_name where the operation will be performed. (required)

  • objects (Array) —

    the array of objects to update in the given Algolia index_name. (required)

  • create_if_not_exists (Boolean) (defaults to: false) —

    whether to create objects that do not exist. (optional, default: false)

  • wait_for_tasks (Boolean) (defaults to: false) —

    whether to wait until every task has been processed. (optional, default: false)

  • batch_size (Integer) (defaults to: 1000) —

    the size of each chunk of objects sent in a single push call. (optional, default: 1000)

  • request_options (Hash) (defaults to: {}) —

    the request options to send along with the query. (optional)

Returns:



3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
# File 'lib/algolia/api/search_client.rb', line 3553

def partial_update_objects_with_transformation(
  index_name,
  objects,
  create_if_not_exists = false,
  wait_for_tasks = false,
  batch_size = 1000,
  request_options = {},
  chunked_options = nil
)
  assert_ingestion_transporter!

  action = create_if_not_exists ? Ingestion::Action::PARTIAL_UPDATE_OBJECT : Ingestion::Action::PARTIAL_UPDATE_OBJECT_NO_CREATE

  @ingestion_transporter.chunked_push(
    index_name,
    objects,
    action,
    wait_for_tasks,
    batch_size,
    nil,
    request_options,
    chunked_options
  )
end

#remove_user_id(user_id, request_options = {}) ⇒ RemoveUserIdResponse

Deletes a user ID and its associated data from the clusters.

Required API Key ACLs:

- admin

Parameters:

  • user_id (String) —

    Unique identifier of the user who makes the search request. (required)

  • 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)

Returns:

  • (RemoveUserIdResponse)


2423
2424
2425
2426
# File 'lib/algolia/api/search_client.rb', line 2423

def remove_user_id(user_id, request_options = {})
  response = remove_user_id_with_http_info(user_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::RemoveUserIdResponse")
end

#remove_user_id_with_http_info(user_id, request_options = {}) ⇒ Http::Response

Deletes a user ID and its associated data from the clusters.

Required API Key ACLs:

- admin

THIS OPERATION IS DEPRECATED

Parameters:

  • user_id (String) —

    Unique identifier of the user who makes the search request. (required)

  • 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)

Returns:



2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
# File 'lib/algolia/api/search_client.rb', line 2387

def remove_user_id_with_http_info(user_id, request_options = {})
  # verify the required parameter 'user_id' is set
  if @api_client.config.client_side_validation && user_id.nil?
    raise ArgumentError, "Parameter `user_id` is required when calling `remove_user_id`."
  end
  # verify the required parameter 'user_id' is not empty
  if @api_client.config.client_side_validation && user_id.empty?
    raise ArgumentError, "Parameter `user_id` is required when calling `remove_user_id`."
  end

  path = "/1/clusters/mapping/{userID}".sub("{" + "userID" + "}", Transport.encode_uri(user_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.remove_user_id",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#replace_all_objects(index_name, objects, batch_size = 1000, scopes = [Search::ScopeType::SETTINGS, Search::ScopeType::RULES, Search::ScopeType::SYNONYMS], request_options = {}, chunked_options = nil) ⇒ Array<ReplaceAllObjectsResponse>

Helper: Replaces all objects (records) in the given index_name with the given objects. A temporary index is created during this process in order to backup your data.

Warning: Calling this method with an empty objects array will delete all records currently in the given index_name.

Parameters:

  • index_name (String) —

    The index_name to replace objects in.

  • objects (Array) —

    The array of objects to store in the given Algolia index_name.

  • batch_size (int) (defaults to: 1000) —

    The size of the chunk of objects. The number of batch calls will be equal to length(objects) / batchSize. Defaults to 1000.

  • scopes (Array) (defaults to: [Search::ScopeType::SETTINGS, Search::ScopeType::RULES, Search::ScopeType::SYNONYMS]) —

    The scopes to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].

  • 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)

Returns:

  • (Array<ReplaceAllObjectsResponse>)


4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
# File 'lib/algolia/api/search_client.rb', line 4147

def replace_all_objects(
  index_name,
  objects,
  batch_size = 1000,
  scopes = [Search::ScopeType::SETTINGS, Search::ScopeType::RULES, Search::ScopeType::SYNONYMS],
  request_options = {},
  chunked_options = nil
)
  request_options = with_request_id(request_options)

  if objects.empty?
    @api_client.logger.warn(
      "replace_all_objects was called with an empty list of objects, which will delete all records currently in the \"#{index_name}\" index."
    )
  end

  opts = Algolia::ChunkedHelperOptions.resolve(
    chunked_options,
    default_max_retries: Algolia::ChunkedHelperOptions::DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES
  )
  tmp_index_name = index_name + "_tmp_" + rand(10_000_000).to_s

  begin
    copy_operation_response = operation_index(
      index_name,
      Search::OperationIndexParams.new(
        operation: Search::OperationType::COPY,
        destination: tmp_index_name,
        scope: scopes
      ),
      request_options
    )

    batch_responses = chunked_batch(
      tmp_index_name,
      objects,
      Search::Action::ADD_OBJECT,
      true,
      batch_size,
      request_options,
      opts
    )

    wait_for_task(
      tmp_index_name,
      copy_operation_response.task_id,
      opts.max_retries,
      Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT,
      request_options
    )

    copy_operation_response = operation_index(
      index_name,
      Search::OperationIndexParams.new(
        operation: Search::OperationType::COPY,
        destination: tmp_index_name,
        scope: scopes
      ),
      request_options
    )

    wait_for_task(
      tmp_index_name,
      copy_operation_response.task_id,
      opts.max_retries,
      Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT,
      request_options
    )

    move_operation_response = operation_index(
      tmp_index_name,
      Search::OperationIndexParams.new(
        operation: Search::OperationType::MOVE,
        destination: index_name
      ),
      request_options
    )

    wait_for_task(
      tmp_index_name,
      move_operation_response.task_id,
      opts.max_retries,
      Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT,
      request_options
    )

    Search::ReplaceAllObjectsResponse.new(
      copy_operation_response: copy_operation_response,
      batch_responses: batch_responses,
      move_operation_response: move_operation_response
    )
  rescue Exception => e
    begin
      delete_index(tmp_index_name, without_timeouts(request_options))
    rescue StandardError => cleanup_error
      @api_client.logger.warn(
        "Failed to delete the temporary index \"#{tmp_index_name}\", please delete it manually: #{cleanup_error}"
      )
    end

    raise e
  end
end

#replace_all_objects_with_transformation(index_name, objects, batch_size = 1000, scopes = [Search::ScopeType::SETTINGS, Search::ScopeType::RULES, Search::ScopeType::SYNONYMS], request_options = {}, chunked_options = nil) ⇒ Search::ReplaceAllObjectsWithTransformationResponse

Helper: Similar to the replace_all_objects method but requires a Push connector to be created first, in order to transform records before indexing them to Algolia. set_transformation_options must have been called, or the client created via SearchClient.with_transformation.

Warning: Calling this method with an empty objects array will delete all records currently in the given index_name.

Parameters:

  • index_name (String) —

    the index_name to replace objects in. (required)

  • objects (Array) —

    the array of objects to store in the given Algolia index_name. (required)

  • batch_size (Integer) (defaults to: 1000) —

    the size of each chunk of objects sent in a single push call. (optional, default: 1000)

  • scopes (Array) (defaults to: [Search::ScopeType::SETTINGS, Search::ScopeType::RULES, Search::ScopeType::SYNONYMS]) —

    the scopes to keep from the index. (optional, default: settings, rules, synonyms)

  • request_options (Hash) (defaults to: {}) —

    the request options to send along with the query. (optional)

Returns:



3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
# File 'lib/algolia/api/search_client.rb', line 3591

def replace_all_objects_with_transformation(
  index_name,
  objects,
  batch_size = 1000,
  scopes = [Search::ScopeType::SETTINGS, Search::ScopeType::RULES, Search::ScopeType::SYNONYMS],
  request_options = {},
  chunked_options = nil
)
  assert_ingestion_transporter!

  # The shared Request-ID only covers the search-side calls: the ingestion
  # push goes to an API that must not receive the header.
  search_request_options = with_request_id(request_options)

  if objects.empty?
    @api_client.logger.warn(
      "replace_all_objects_with_transformation was called with an empty list of objects, which will delete all records currently in the \"#{index_name}\" index."
    )
  end

  opts = Algolia::ChunkedHelperOptions.resolve(
    chunked_options,
    default_max_retries: Algolia::ChunkedHelperOptions::DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES
  )
  tmp_index_name = index_name + "_tmp_" + rand(10_000_000).to_s

  begin
    copy_operation_response = operation_index(
      index_name,
      Search::OperationIndexParams.new(
        operation: Search::OperationType::COPY,
        destination: tmp_index_name,
        scope: scopes
      ),
      search_request_options
    )

    watch_responses = @ingestion_transporter.chunked_push(
      tmp_index_name,
      objects,
      Ingestion::Action::ADD_OBJECT,
      true,
      batch_size,
      index_name,
      request_options,
      opts
    )

    wait_for_task(
      tmp_index_name,
      copy_operation_response.task_id,
      opts.max_retries,
      Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT,
      search_request_options
    )

    copy_operation_response = operation_index(
      index_name,
      Search::OperationIndexParams.new(
        operation: Search::OperationType::COPY,
        destination: tmp_index_name,
        scope: scopes
      ),
      search_request_options
    )

    wait_for_task(
      tmp_index_name,
      copy_operation_response.task_id,
      opts.max_retries,
      Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT,
      search_request_options
    )

    move_operation_response = operation_index(
      tmp_index_name,
      Search::OperationIndexParams.new(
        operation: Search::OperationType::MOVE,
        destination: index_name
      ),
      search_request_options
    )

    wait_for_task(
      tmp_index_name,
      move_operation_response.task_id,
      opts.max_retries,
      Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT,
      search_request_options
    )

    search_watch_responses = watch_responses.map do |wr|
      Search::WatchResponse.build_from_hash(wr.to_hash)
    end

    Search::ReplaceAllObjectsWithTransformationResponse.new(
      copy_operation_response: copy_operation_response,
      watch_responses: search_watch_responses,
      move_operation_response: move_operation_response
    )
  rescue Exception => e
    begin
      delete_index(tmp_index_name, without_timeouts(search_request_options))
    rescue StandardError => cleanup_error
      @api_client.logger.warn(
        "Failed to delete the temporary index \"#{tmp_index_name}\", please delete it manually: #{cleanup_error}"
      )
    end

    raise e
  end
end

#replace_sources(source, request_options = {}) ⇒ ReplaceSourceResponse

Replaces the list of allowed sources.

Required API Key ACLs:

- admin

Parameters:

  • source (Array<Source>) —

    Allowed sources. (required)

  • 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)

Returns:

  • (ReplaceSourceResponse)


2467
2468
2469
2470
# File 'lib/algolia/api/search_client.rb', line 2467

def replace_sources(source, request_options = {})
  response = replace_sources_with_http_info(source, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::ReplaceSourceResponse")
end

#replace_sources_with_http_info(source, request_options = {}) ⇒ Http::Response

Replaces the list of allowed sources.

Required API Key ACLs:

- admin

Parameters:

  • source (Array<Source>) —

    Allowed sources. (required)

  • 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)

Returns:



2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
# File 'lib/algolia/api/search_client.rb', line 2435

def replace_sources_with_http_info(source, request_options = {})
  # verify the required parameter 'source' is set
  if @api_client.config.client_side_validation && source.nil?
    raise ArgumentError, "Parameter `source` is required when calling `replace_sources`."
  end

  path = "/1/security/sources"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(source)

  new_options = request_options.merge(
    :operation => :"SearchClient.replace_sources",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#restore_api_key(key, request_options = {}) ⇒ AddApiKeyResponse

Restores a deleted API key. Restoring resets the validity attribute to 0. Algolia stores up to 1,000 API keys per application. If you create more, the oldest API keys are deleted and can't be restored.

Required API Key ACLs:

- admin

Parameters:

  • key (String) —

    API key. (required)

  • 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)

Returns:

  • (AddApiKeyResponse)


2515
2516
2517
2518
# File 'lib/algolia/api/search_client.rb', line 2515

def restore_api_key(key, request_options = {})
  response = restore_api_key_with_http_info(key, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::AddApiKeyResponse")
end

#restore_api_key_with_http_info(key, request_options = {}) ⇒ Http::Response

Restores a deleted API key. Restoring resets the validity attribute to 0. Algolia stores up to 1,000 API keys per application. If you create more, the oldest API keys are deleted and can't be restored.

Required API Key ACLs:

- admin

Parameters:

  • key (String) —

    API key. (required)

  • 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)

Returns:



2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
# File 'lib/algolia/api/search_client.rb', line 2479

def restore_api_key_with_http_info(key, request_options = {})
  # verify the required parameter 'key' is set
  if @api_client.config.client_side_validation && key.nil?
    raise ArgumentError, "Parameter `key` is required when calling `restore_api_key`."
  end
  # verify the required parameter 'key' is not empty
  if @api_client.config.client_side_validation && key.empty?
    raise ArgumentError, "Parameter `key` is required when calling `restore_api_key`."
  end

  path = "/1/keys/{key}/restore".sub("{" + "key" + "}", Transport.encode_uri(key.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"SearchClient.restore_api_key",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#save_object(index_name, body, request_options = {}) ⇒ SaveObjectResponse

Adds a record to an index or replaces it. - If the record doesn't have an object ID, a new record with an auto-generated object ID is added to your index. - If a record with the specified object ID exists, the existing record is replaced. - If a record with the specified object ID doesn't exist, a new record is added to your index. - If you add a record to an index that doesn't exist yet, a new index is created. To update some attributes of a record, use the partial operation. To add, update, or replace multiple records, use the batch operation. This operation is subject to indexing rate limits.

Required API Key ACLs:

- addObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • body (Object) —

    The record. A schemaless object with attributes that are useful in the context of search and discovery. (required)

  • 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)

Returns:

  • (SaveObjectResponse)


2569
2570
2571
2572
# File 'lib/algolia/api/search_client.rb', line 2569

def save_object(index_name, body, request_options = {})
  response = save_object_with_http_info(index_name, body, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::SaveObjectResponse")
end

#save_object_with_http_info(index_name, body, request_options = {}) ⇒ Http::Response

Adds a record to an index or replaces it. - If the record doesn't have an object ID, a new record with an auto-generated object ID is added to your index. - If a record with the specified object ID exists, the existing record is replaced. - If a record with the specified object ID doesn't exist, a new record is added to your index. - If you add a record to an index that doesn't exist yet, a new index is created. To update some attributes of a record, use the partial operation. To add, update, or replace multiple records, use the batch operation. This operation is subject to indexing rate limits.

Required API Key ACLs:

- addObject

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • body (Object) —

    The record. A schemaless object with attributes that are useful in the context of search and discovery. (required)

  • 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)

Returns:



2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
# File 'lib/algolia/api/search_client.rb', line 2528

def save_object_with_http_info(index_name, body, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `save_object`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `save_object`."
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    raise ArgumentError, "Parameter `body` is required when calling `save_object`."
  end

  path = "/1/indexes/{indexName}".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(body)

  new_options = request_options.merge(
    :operation => :"SearchClient.save_object",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#save_objects(index_name, objects, wait_for_tasks = false, batch_size = 1000, request_options = {}, chunked_options = nil) ⇒ BatchResponse

Helper: Saves the given array of objects in the given index. The chunked_batch helper is used under the hood, which creates a batch requests with at most 1000 objects in it.

Parameters:

  • index_name (String) —

    : The index_name to save objects in.

  • objects (Array) —

    : The array of objects to store in the given Algolia indexName.

  • wait_for_tasks (Boolean) (defaults to: false) —

    : Whether or not we should wait until every batch tasks has been processed, this operation may slow the total execution time of this method but is more reliable.

  • batch_size (int) (defaults to: 1000) —

    The size of the chunk of objects. The number of batch calls will be equal to length(objects) / batchSize. Defaults to 1000.

  • 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)

Returns:

  • (BatchResponse)


4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
# File 'lib/algolia/api/search_client.rb', line 4011

def save_objects(
  index_name,
  objects,
  wait_for_tasks = false,
  batch_size = 1000,
  request_options = {},
  chunked_options = nil
)
  chunked_batch(
    index_name,
    objects,
    Search::Action::ADD_OBJECT,
    wait_for_tasks,
    batch_size,
    request_options,
    chunked_options
  )
end

#save_objects_with_transformation(index_name, objects, wait_for_tasks = false, batch_size = 1000, request_options = {}, chunked_options = nil) ⇒ Array<Ingestion::WatchResponse>

Helper: Similar to the save_objects method but requires a Push connector to be created first, in order to transform records before indexing them to Algolia. set_transformation_options must have been called, or the client created via SearchClient.with_transformation.

Parameters:

  • index_name (String) —

    the index_name where the operation will be performed. (required)

  • objects (Array) —

    the array of objects to store in the given Algolia index_name. (required)

  • wait_for_tasks (Boolean) (defaults to: false) —

    whether to wait until every task has been processed. (optional, default: false)

  • batch_size (Integer) (defaults to: 1000) —

    the size of each chunk of objects sent in a single push call. (optional, default: 1000)

  • request_options (Hash) (defaults to: {}) —

    the request options to send along with the query. (optional)

Returns:



3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
# File 'lib/algolia/api/search_client.rb', line 3519

def save_objects_with_transformation(
  index_name,
  objects,
  wait_for_tasks = false,
  batch_size = 1000,
  request_options = {},
  chunked_options = nil
)
  assert_ingestion_transporter!

  @ingestion_transporter.chunked_push(
    index_name,
    objects,
    Ingestion::Action::ADD_OBJECT,
    wait_for_tasks,
    batch_size,
    nil,
    request_options,
    chunked_options
  )
end

#save_rule(index_name, algolia_object_id, rule, forward_to_replicas = nil, request_options = {}) ⇒ UpdatedAtResponse

If a rule with the specified object ID doesn't exist, it's created. Otherwise, the existing rule is replaced. To create or update more than one rule, use the batch operation.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique identifier of a rule object. (required)

  • rule (Rule) —

    (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:

  • (UpdatedAtResponse)


2638
2639
2640
2641
# File 'lib/algolia/api/search_client.rb', line 2638

def save_rule(index_name, algolia_object_id, rule, forward_to_replicas = nil, request_options = {})
  response = save_rule_with_http_info(index_name, algolia_object_id, rule, forward_to_replicas, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
end

#save_rule_with_http_info(index_name, algolia_object_id, rule, forward_to_replicas = nil, request_options = {}) ⇒ Http::Response

If a rule with the specified object ID doesn't exist, it's created. Otherwise, the existing rule is replaced. To create or update more than one rule, use the batch operation.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique identifier of a rule object. (required)

  • rule (Rule) —

    (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:



2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
# File 'lib/algolia/api/search_client.rb', line 2584

def save_rule_with_http_info(index_name, algolia_object_id, rule, forward_to_replicas = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `save_rule`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `save_rule`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `save_rule`."
  end
  # verify the required parameter 'algolia_object_id' is not empty
  if @api_client.config.client_side_validation && algolia_object_id.empty?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `save_rule`."
  end
  # verify the required parameter 'rule' is set
  if @api_client.config.client_side_validation && rule.nil?
    raise ArgumentError, "Parameter `rule` is required when calling `save_rule`."
  end

  path = "/1/indexes/{indexName}/rules/{objectID}"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "objectID" + "}", Transport.encode_uri(algolia_object_id.to_s))
  query_params = {}
  query_params[:forwardToReplicas] = forward_to_replicas unless forward_to_replicas.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(rule)

  new_options = request_options.merge(
    :operation => :"SearchClient.save_rule",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#save_rules(index_name, rules, forward_to_replicas = nil, clear_existing_rules = nil, request_options = {}) ⇒ UpdatedAtResponse

Create or update multiple rules. If a rule with the specified object ID doesn't exist, Algolia creates a new one. Otherwise, existing rules are replaced. This operation is subject to indexing rate limits.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • rules (Array<Rule>) —

    (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • clear_existing_rules (Boolean) (defaults to: nil) —

    Whether existing rules should be deleted before adding this batch.

  • 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)

Returns:

  • (UpdatedAtResponse)


2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
# File 'lib/algolia/api/search_client.rb', line 2704

def save_rules(index_name, rules, forward_to_replicas = nil, clear_existing_rules = nil, request_options = {})
  response = save_rules_with_http_info(
    index_name,
    rules,
    forward_to_replicas,
    clear_existing_rules,
    request_options
  )
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
end

#save_rules_with_http_info(index_name, rules, forward_to_replicas = nil, clear_existing_rules = nil, request_options = {}) ⇒ Http::Response

Create or update multiple rules. If a rule with the specified object ID doesn't exist, Algolia creates a new one. Otherwise, existing rules are replaced. This operation is subject to indexing rate limits.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • rules (Array<Rule>) —

    (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • clear_existing_rules (Boolean) (defaults to: nil) —

    Whether existing rules should be deleted before adding this batch.

  • 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)

Returns:



2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
# File 'lib/algolia/api/search_client.rb', line 2653

def save_rules_with_http_info(
  index_name,
  rules,
  forward_to_replicas = nil,
  clear_existing_rules = nil,
  request_options = {}
)
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `save_rules`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `save_rules`."
  end
  # verify the required parameter 'rules' is set
  if @api_client.config.client_side_validation && rules.nil?
    raise ArgumentError, "Parameter `rules` is required when calling `save_rules`."
  end

  path = "/1/indexes/{indexName}/rules/batch".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params[:forwardToReplicas] = forward_to_replicas unless forward_to_replicas.nil?
  query_params[:clearExistingRules] = clear_existing_rules unless clear_existing_rules.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(rules)

  new_options = request_options.merge(
    :operation => :"SearchClient.save_rules",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#save_synonym(index_name, algolia_object_id, synonym_hit, forward_to_replicas = nil, request_options = {}) ⇒ SaveSynonymResponse

If a synonym with the specified object ID doesn't exist, Algolia adds a new one. Otherwise, the existing synonym is replaced. To add multiple synonyms in a single API request, use the batch operation.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique identifier of a synonym object. (required)

  • synonym_hit (SynonymHit) —

    (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:

  • (SaveSynonymResponse)


2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
# File 'lib/algolia/api/search_client.rb', line 2785

def save_synonym(index_name, algolia_object_id, synonym_hit, forward_to_replicas = nil, request_options = {})
  response = save_synonym_with_http_info(
    index_name,
    algolia_object_id,
    synonym_hit,
    forward_to_replicas,
    request_options
  )
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::SaveSynonymResponse")
end

#save_synonym_with_http_info(index_name, algolia_object_id, synonym_hit, forward_to_replicas = nil, request_options = {}) ⇒ Http::Response

If a synonym with the specified object ID doesn't exist, Algolia adds a new one. Otherwise, the existing synonym is replaced. To add multiple synonyms in a single API request, use the batch operation.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • algolia_object_id (String) —

    Unique identifier of a synonym object. (required)

  • synonym_hit (SynonymHit) —

    (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:



2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
# File 'lib/algolia/api/search_client.rb', line 2725

def save_synonym_with_http_info(
  index_name,
  algolia_object_id,
  synonym_hit,
  forward_to_replicas = nil,
  request_options = {}
)
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `save_synonym`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `save_synonym`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `save_synonym`."
  end
  # verify the required parameter 'algolia_object_id' is not empty
  if @api_client.config.client_side_validation && algolia_object_id.empty?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `save_synonym`."
  end
  # verify the required parameter 'synonym_hit' is set
  if @api_client.config.client_side_validation && synonym_hit.nil?
    raise ArgumentError, "Parameter `synonym_hit` is required when calling `save_synonym`."
  end

  path = "/1/indexes/{indexName}/synonyms/{objectID}"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "objectID" + "}", Transport.encode_uri(algolia_object_id.to_s))
  query_params = {}
  query_params[:forwardToReplicas] = forward_to_replicas unless forward_to_replicas.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(synonym_hit)

  new_options = request_options.merge(
    :operation => :"SearchClient.save_synonym",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#save_synonyms(index_name, synonym_hit, forward_to_replicas = nil, replace_existing_synonyms = nil, request_options = {}) ⇒ UpdatedAtResponse

If a synonym with the objectID doesn't exist, Algolia adds a new one. Otherwise, existing synonyms are replaced. This operation is subject to indexing rate limits.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • synonym_hit (Array<SynonymHit>) —

    (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • replace_existing_synonyms (Boolean) (defaults to: nil) —

    Whether to replace all synonyms in the index with the ones sent with this request.

  • 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)

Returns:

  • (UpdatedAtResponse)


2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
# File 'lib/algolia/api/search_client.rb', line 2857

def save_synonyms(
  index_name,
  synonym_hit,
  forward_to_replicas = nil,
  replace_existing_synonyms = nil,
  request_options = {}
)
  response = save_synonyms_with_http_info(
    index_name,
    synonym_hit,
    forward_to_replicas,
    replace_existing_synonyms,
    request_options
  )
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
end

#save_synonyms_with_http_info(index_name, synonym_hit, forward_to_replicas = nil, replace_existing_synonyms = nil, request_options = {}) ⇒ Http::Response

If a synonym with the objectID doesn't exist, Algolia adds a new one. Otherwise, existing synonyms are replaced. This operation is subject to indexing rate limits.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • synonym_hit (Array<SynonymHit>) —

    (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • replace_existing_synonyms (Boolean) (defaults to: nil) —

    Whether to replace all synonyms in the index with the ones sent with this request.

  • 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)

Returns:



2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
# File 'lib/algolia/api/search_client.rb', line 2806

def save_synonyms_with_http_info(
  index_name,
  synonym_hit,
  forward_to_replicas = nil,
  replace_existing_synonyms = nil,
  request_options = {}
)
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `save_synonyms`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `save_synonyms`."
  end
  # verify the required parameter 'synonym_hit' is set
  if @api_client.config.client_side_validation && synonym_hit.nil?
    raise ArgumentError, "Parameter `synonym_hit` is required when calling `save_synonyms`."
  end

  path = "/1/indexes/{indexName}/synonyms/batch".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params[:forwardToReplicas] = forward_to_replicas unless forward_to_replicas.nil?
  query_params[:replaceExistingSynonyms] = replace_existing_synonyms unless replace_existing_synonyms.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(synonym_hit)

  new_options = request_options.merge(
    :operation => :"SearchClient.save_synonyms",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#search(search_method_params, request_options = {}) ⇒ SearchResponses

Runs multiple search queries against one or more indices in a single API request. Use cases include: - Searching different indices, such as products and marketing content. - Run multiple queries on the same index with different parameters or filters. If you know the expected result type, use the searchForHits or searchForFacets helper to simplify the response format.

Required API Key ACLs:

- search

Parameters:

  • search_method_params (SearchMethodParams) —

    Multi-query search request body. Results are returned in the same order as the requests. (required)

  • 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)

Returns:

  • (SearchResponses)


2913
2914
2915
2916
# File 'lib/algolia/api/search_client.rb', line 2913

def search(search_method_params, request_options = {})
  response = search_with_http_info(search_method_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::SearchResponses")
end

#search_dictionary_entries(dictionary_name, search_dictionary_entries_params, request_options = {}) ⇒ SearchDictionaryEntriesResponse

Searches for standard and custom dictionary entries.

Required API Key ACLs:

- settings

Parameters:

  • dictionary_name (DictionaryType) —

    Dictionary type in which to search. (required)

  • search_dictionary_entries_params (SearchDictionaryEntriesParams) —

    (required)

  • 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)

Returns:

  • (SearchDictionaryEntriesResponse)


2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
# File 'lib/algolia/api/search_client.rb', line 2973

def search_dictionary_entries(dictionary_name, search_dictionary_entries_params, request_options = {})
  response = search_dictionary_entries_with_http_info(
    dictionary_name,
    search_dictionary_entries_params,
    request_options
  )
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Search::SearchDictionaryEntriesResponse"
  )
end

#search_dictionary_entries_with_http_info(dictionary_name, search_dictionary_entries_params, request_options = {}) ⇒ Http::Response

Searches for standard and custom dictionary entries.

Required API Key ACLs:

- settings

Parameters:

  • dictionary_name (DictionaryType) —

    Dictionary type in which to search. (required)

  • search_dictionary_entries_params (SearchDictionaryEntriesParams) —

    (required)

  • 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)

Returns:



2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
# File 'lib/algolia/api/search_client.rb', line 2926

def search_dictionary_entries_with_http_info(
  dictionary_name,
  search_dictionary_entries_params,
  request_options = {}
)
  # verify the required parameter 'dictionary_name' is set
  if @api_client.config.client_side_validation && dictionary_name.nil?
    raise ArgumentError, "Parameter `dictionary_name` is required when calling `search_dictionary_entries`."
  end
  # verify the required parameter 'search_dictionary_entries_params' is set
  if @api_client.config.client_side_validation && search_dictionary_entries_params.nil?
    raise(
      ArgumentError,
      "Parameter `search_dictionary_entries_params` is required when calling `search_dictionary_entries`."
    )
  end

  path = "/1/dictionaries/{dictionaryName}/search".sub(
    "{" + "dictionaryName" + "}",
    Transport.encode_uri(dictionary_name.to_s)
  )
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(search_dictionary_entries_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.search_dictionary_entries",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#search_for_facet_values(index_name, facet_name, search_for_facet_values_request = nil, request_options = {}) ⇒ SearchForFacetValuesResponse

Searches for values of a specified facet attribute. - By default, facet values are sorted by decreasing count. You can adjust this with the sortFacetValueBy parameter. - Searching for facet values doesn't work if you have more than 65 searchable facets and searchable attributes combined.

Required API Key ACLs:

- search

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • facet_name (String) —

    Facet attribute in which to search for values. This attribute must be included in the attributesForFaceting index setting with the searchable() modifier. (required)

  • search_for_facet_values_request (SearchForFacetValuesRequest) (defaults to: nil)
  • 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)

Returns:

  • (SearchForFacetValuesResponse)


3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
# File 'lib/algolia/api/search_client.rb', line 3047

def search_for_facet_values(index_name, facet_name, search_for_facet_values_request = nil, request_options = {})
  response = search_for_facet_values_with_http_info(
    index_name,
    facet_name,
    search_for_facet_values_request,
    request_options
  )
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Search::SearchForFacetValuesResponse"
  )
end

#search_for_facet_values_with_http_info(index_name, facet_name, search_for_facet_values_request = nil, request_options = {}) ⇒ Http::Response

Searches for values of a specified facet attribute. - By default, facet values are sorted by decreasing count. You can adjust this with the sortFacetValueBy parameter. - Searching for facet values doesn't work if you have more than 65 searchable facets and searchable attributes combined.

Required API Key ACLs:

- search

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • facet_name (String) —

    Facet attribute in which to search for values. This attribute must be included in the attributesForFaceting index setting with the searchable() modifier. (required)

  • search_for_facet_values_request (SearchForFacetValuesRequest) (defaults to: nil)
  • 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)

Returns:



2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
# File 'lib/algolia/api/search_client.rb', line 2994

def search_for_facet_values_with_http_info(
  index_name,
  facet_name,
  search_for_facet_values_request = nil,
  request_options = {}
)
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `search_for_facet_values`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `search_for_facet_values`."
  end
  # verify the required parameter 'facet_name' is set
  if @api_client.config.client_side_validation && facet_name.nil?
    raise ArgumentError, "Parameter `facet_name` is required when calling `search_for_facet_values`."
  end
  # verify the required parameter 'facet_name' is not empty
  if @api_client.config.client_side_validation && facet_name.empty?
    raise ArgumentError, "Parameter `facet_name` is required when calling `search_for_facet_values`."
  end

  path = "/1/indexes/{indexName}/facets/{facetName}/query"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "facetName" + "}", Transport.encode_uri(facet_name.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(search_for_facet_values_request)

  new_options = request_options.merge(
    :operation => :"SearchClient.search_for_facet_values",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#search_rules(index_name, search_rules_params = nil, request_options = {}) ⇒ SearchRulesResponse

Searches for rules in your index.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • search_rules_params (SearchRulesParams) (defaults to: nil)
  • 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)

Returns:

  • (SearchRulesResponse)


3105
3106
3107
3108
# File 'lib/algolia/api/search_client.rb', line 3105

def search_rules(index_name, search_rules_params = nil, request_options = {})
  response = search_rules_with_http_info(index_name, search_rules_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::SearchRulesResponse")
end

#search_rules_with_http_info(index_name, search_rules_params = nil, request_options = {}) ⇒ Http::Response

Searches for rules in your index.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • search_rules_params (SearchRulesParams) (defaults to: nil)
  • 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)

Returns:



3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
# File 'lib/algolia/api/search_client.rb', line 3068

def search_rules_with_http_info(index_name, search_rules_params = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `search_rules`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `search_rules`."
  end

  path = "/1/indexes/{indexName}/rules/search".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(search_rules_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.search_rules",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#search_single_index(index_name, search_params = nil, request_options = {}) ⇒ SearchResponse

Searches a single index and returns matching search results as hits. This method lets you retrieve up to 1,000 hits. If you need more, use the browse operation or increase the paginatedLimitedTo index setting.

Required API Key ACLs:

- search

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • search_params (SearchParams) (defaults to: nil)
  • 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)

Returns:

  • (SearchResponse)


3155
3156
3157
3158
# File 'lib/algolia/api/search_client.rb', line 3155

def search_single_index(index_name, search_params = nil, request_options = {})
  response = search_single_index_with_http_info(index_name, search_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::SearchResponse")
end

#search_single_index_with_http_info(index_name, search_params = nil, request_options = {}) ⇒ Http::Response

Searches a single index and returns matching search results as hits. This method lets you retrieve up to 1,000 hits. If you need more, use the browse operation or increase the paginatedLimitedTo index setting.

Required API Key ACLs:

- search

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • search_params (SearchParams) (defaults to: nil)
  • 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)

Returns:



3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
# File 'lib/algolia/api/search_client.rb', line 3118

def search_single_index_with_http_info(index_name, search_params = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `search_single_index`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `search_single_index`."
  end

  path = "/1/indexes/{indexName}/query".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(search_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.search_single_index",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#search_synonyms(index_name, search_synonyms_params = nil, request_options = {}) ⇒ SearchSynonymsResponse

Searches for synonyms in your index.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • search_synonyms_params (SearchSynonymsParams) (defaults to: nil) —

    Body of the searchSynonyms operation.

  • 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)

Returns:

  • (SearchSynonymsResponse)


3208
3209
3210
3211
# File 'lib/algolia/api/search_client.rb', line 3208

def search_synonyms(index_name, search_synonyms_params = nil, request_options = {})
  response = search_synonyms_with_http_info(index_name, search_synonyms_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::SearchSynonymsResponse")
end

#search_synonyms_with_http_info(index_name, search_synonyms_params = nil, request_options = {}) ⇒ Http::Response

Searches for synonyms in your index.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • search_synonyms_params (SearchSynonymsParams) (defaults to: nil) —

    Body of the searchSynonyms operation.

  • 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)

Returns:



3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
# File 'lib/algolia/api/search_client.rb', line 3168

def search_synonyms_with_http_info(index_name, search_synonyms_params = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `search_synonyms`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `search_synonyms`."
  end

  path = "/1/indexes/{indexName}/synonyms/search".sub(
    "{" + "indexName" + "}",
    Transport.encode_uri(index_name.to_s)
  )
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(search_synonyms_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.search_synonyms",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#search_user_ids(search_user_ids_params, request_options = {}) ⇒ SearchUserIdsResponse

Since it can take a few seconds to get the data from the different clusters, the response isn't real-time. To ensure rapid updates, the user IDs index isn't built at the same time as the mapping. Instead, it's built every 12 hours, at the same time as the update of user ID usage. For example, if you add or move a user ID, the search will show an old value until the next time the mapping is rebuilt (every 12 hours).

Required API Key ACLs:

- admin

Parameters:

  • search_user_ids_params (SearchUserIdsParams) —

    (required)

  • 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)

Returns:

  • (SearchUserIdsResponse)


3253
3254
3255
3256
# File 'lib/algolia/api/search_client.rb', line 3253

def search_user_ids(search_user_ids_params, request_options = {})
  response = search_user_ids_with_http_info(search_user_ids_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::SearchUserIdsResponse")
end

#search_user_ids_with_http_info(search_user_ids_params, request_options = {}) ⇒ Http::Response

Since it can take a few seconds to get the data from the different clusters, the response isn't real-time. To ensure rapid updates, the user IDs index isn't built at the same time as the mapping. Instead, it's built every 12 hours, at the same time as the update of user ID usage. For example, if you add or move a user ID, the search will show an old value until the next time the mapping is rebuilt (every 12 hours).

Required API Key ACLs:

- admin

THIS OPERATION IS DEPRECATED

Parameters:

  • search_user_ids_params (SearchUserIdsParams) —

    (required)

  • 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)

Returns:



3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
# File 'lib/algolia/api/search_client.rb', line 3221

def search_user_ids_with_http_info(search_user_ids_params, request_options = {})
  # verify the required parameter 'search_user_ids_params' is set
  if @api_client.config.client_side_validation && search_user_ids_params.nil?
    raise ArgumentError, "Parameter `search_user_ids_params` is required when calling `search_user_ids`."
  end

  path = "/1/clusters/mapping/search"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(search_user_ids_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.search_user_ids",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#search_with_http_info(search_method_params, request_options = {}) ⇒ Http::Response

Runs multiple search queries against one or more indices in a single API request. Use cases include: - Searching different indices, such as products and marketing content. - Run multiple queries on the same index with different parameters or filters. If you know the expected result type, use the searchForHits or searchForFacets helper to simplify the response format.

Required API Key ACLs:

- search

Parameters:

  • search_method_params (SearchMethodParams) —

    Multi-query search request body. Results are returned in the same order as the requests. (required)

  • 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)

Returns:



2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
# File 'lib/algolia/api/search_client.rb', line 2881

def search_with_http_info(search_method_params, request_options = {})
  # verify the required parameter 'search_method_params' is set
  if @api_client.config.client_side_validation && search_method_params.nil?
    raise ArgumentError, "Parameter `search_method_params` is required when calling `search`."
  end

  path = "/1/indexes/*/queries"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(search_method_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.search",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#set_client_api_key(api_key) ⇒ void

This method returns an undefined value.

Helper method to switch the API key used to authenticate the requests.

Parameters:

  • api_key (String) —

    the new API key to use.



129
130
131
132
133
# File 'lib/algolia/api/search_client.rb', line 129

def set_client_api_key(api_key)
  @api_client.set_client_api_key(api_key)

  self
end

#set_dictionary_settings(dictionary_settings_params, request_options = {}) ⇒ UpdatedAtResponse

Turns standard stop word dictionary entries on or off for a given language.

Required API Key ACLs:

- editSettings

Parameters:

  • dictionary_settings_params (DictionarySettingsParams) —

    (required)

  • 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)

Returns:

  • (UpdatedAtResponse)


3300
3301
3302
3303
# File 'lib/algolia/api/search_client.rb', line 3300

def set_dictionary_settings(dictionary_settings_params, request_options = {})
  response = set_dictionary_settings_with_http_info(dictionary_settings_params, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
end

#set_dictionary_settings_with_http_info(dictionary_settings_params, request_options = {}) ⇒ Http::Response

Turns standard stop word dictionary entries on or off for a given language.

Required API Key ACLs:

- editSettings

Parameters:

  • dictionary_settings_params (DictionarySettingsParams) —

    (required)

  • 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)

Returns:



3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
# File 'lib/algolia/api/search_client.rb', line 3265

def set_dictionary_settings_with_http_info(dictionary_settings_params, request_options = {})
  # verify the required parameter 'dictionary_settings_params' is set
  if @api_client.config.client_side_validation && dictionary_settings_params.nil?
    raise(
      ArgumentError,
      "Parameter `dictionary_settings_params` is required when calling `set_dictionary_settings`."
    )
  end

  path = "/1/dictionaries/*/settings"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(dictionary_settings_params)

  new_options = request_options.merge(
    :operation => :"SearchClient.set_dictionary_settings",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#set_settings(index_name, index_settings, forward_to_replicas = nil, request_options = {}) ⇒ UpdatedAtResponse

Update the specified index settings. Index settings that you don't specify are left unchanged. Specify null to reset a setting to its default value. For best performance, update the index settings before you add new records to your index.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • index_settings (IndexSettings) —

    (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:

  • (UpdatedAtResponse)


3357
3358
3359
3360
# File 'lib/algolia/api/search_client.rb', line 3357

def set_settings(index_name, index_settings, forward_to_replicas = nil, request_options = {})
  response = set_settings_with_http_info(index_name, index_settings, forward_to_replicas, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
end

#set_settings_with_http_info(index_name, index_settings, forward_to_replicas = nil, request_options = {}) ⇒ Http::Response

Update the specified index settings. Index settings that you don't specify are left unchanged. Specify null to reset a setting to its default value. For best performance, update the index settings before you add new records to your index.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String) —

    Name of the index on which to perform the operation. (required)

  • index_settings (IndexSettings) —

    (required)

  • forward_to_replicas (Boolean) (defaults to: nil) —

    Whether changes are applied to replica indices.

  • 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)

Returns:



3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
# File 'lib/algolia/api/search_client.rb', line 3314

def set_settings_with_http_info(index_name, index_settings, forward_to_replicas = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `set_settings`."
  end
  # verify the required parameter 'index_name' is not empty
  if @api_client.config.client_side_validation && index_name.empty?
    raise ArgumentError, "Parameter `index_name` is required when calling `set_settings`."
  end
  # verify the required parameter 'index_settings' is set
  if @api_client.config.client_side_validation && index_settings.nil?
    raise ArgumentError, "Parameter `index_settings` is required when calling `set_settings`."
  end

  path = "/1/indexes/{indexName}/settings".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
  query_params = {}
  query_params[:forwardToReplicas] = forward_to_replicas unless forward_to_replicas.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(index_settings)

  new_options = request_options.merge(
    :operation => :"SearchClient.set_settings",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#set_transformation_options(transformation_options) ⇒ Object

Helper: Sets (or replaces) the ingestion transporter used by *_with_transformation helpers.

Parameters:

  • transformation_options (TransformationOptions) —

    the transformation options including region and optional ingestion transporter overrides. (required)

Raises:

  • (ArgumentError)


3494
3495
3496
3497
# File 'lib/algolia/api/search_client.rb', line 3494

def set_transformation_options(transformation_options)
  raise ArgumentError, "`transformation_options` must not be nil" if transformation_options.nil?
  @ingestion_transporter = _build_ingestion_transporter(transformation_options)
end

#update_api_key(key, api_key, request_options = {}) ⇒ UpdateApiKeyResponse

Replaces the permissions of an existing API key. Any unspecified attribute resets that attribute to its default value.

Required API Key ACLs:

- admin

Parameters:

  • key (String) —

    API key. (required)

  • api_key (ApiKey) —

    (required)

  • 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)

Returns:

  • (UpdateApiKeyResponse)


3411
3412
3413
3414
# File 'lib/algolia/api/search_client.rb', line 3411

def update_api_key(key, api_key, request_options = {})
  response = update_api_key_with_http_info(key, api_key, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdateApiKeyResponse")
end

#update_api_key_with_http_info(key, api_key, request_options = {}) ⇒ Http::Response

Replaces the permissions of an existing API key. Any unspecified attribute resets that attribute to its default value.

Required API Key ACLs:

- admin

Parameters:

  • key (String) —

    API key. (required)

  • api_key (ApiKey) —

    (required)

  • 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)

Returns:



3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
# File 'lib/algolia/api/search_client.rb', line 3370

def update_api_key_with_http_info(key, api_key, request_options = {})
  # verify the required parameter 'key' is set
  if @api_client.config.client_side_validation && key.nil?
    raise ArgumentError, "Parameter `key` is required when calling `update_api_key`."
  end
  # verify the required parameter 'key' is not empty
  if @api_client.config.client_side_validation && key.empty?
    raise ArgumentError, "Parameter `key` is required when calling `update_api_key`."
  end
  # verify the required parameter 'api_key' is set
  if @api_client.config.client_side_validation && api_key.nil?
    raise ArgumentError, "Parameter `api_key` is required when calling `update_api_key`."
  end

  path = "/1/keys/{key}".sub("{" + "key" + "}", Transport.encode_uri(key.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(api_key)

  new_options = request_options.merge(
    :operation => :"SearchClient.update_api_key",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#wait_for_api_key(key, operation, api_key = Search::ApiKey.new, max_retries = Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES, timeout = Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT, request_options = {}) ⇒ Http::Response

Helper: Wait for an API key to be added, updated or deleted based on a given operation.

Parameters:

  • key (String) —

    the key that has been added, deleted or updated.

  • operation (String) —

    the operation that was done on a key.

  • api_key (Hash) (defaults to: Search::ApiKey.new) —

    necessary to know if an update operation has been processed, compare fields of the response with it.

  • max_retries (Integer) (defaults to: Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES) —

    the maximum number of retries. (optional, default to Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES)

  • timeout (Proc) (defaults to: Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT) —

    the function to decide how long to wait between retries. (optional, default to Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT)

  • request_options (Hash) (defaults to: {}) —

    the requestOptions to send along with the query, they will be forwarded to the getApikey method and merged with the transporter requestOptions.

Returns:

Raises:



3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
# File 'lib/algolia/api/search_client.rb', line 3777

def wait_for_api_key(
  key,
  operation,
  api_key = Search::ApiKey.new,
  max_retries = Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES,
  timeout = Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT,
  request_options = {}
)
  request_options = with_request_id(request_options)
  api_key = api_client.object_to_hash(api_key)

  retries = 0
  if operation == "update"
    raise ArgumentError, "`api_key` is required when waiting for an `update` operation." if api_key.nil?
    while retries < max_retries
      updated_key = get_api_key(key, request_options)
      updated_key_hash = updated_key.to_hash
      equals = true
      api_key.each do |k, v|
        equals &&= updated_key_hash[k] == v
      end

      return updated_key if equals

      retries += 1
      sleep(timeout.call(retries) / 1000.0)
    end

    raise(
      ApiError,
      "Stopped waiting for the task after #{max_retries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher max_retries."
    )
  end

  while retries < max_retries
    begin
      res = get_api_key(key, request_options)
      return res if operation == "add"
    rescue AlgoliaHttpError => e
      if e.code == 404
        return nil if operation == "delete"
      else
        raise e
      end
    end

    retries += 1
    sleep(timeout.call(retries) / 1000.0)
  end

  raise(
    ApiError,
    "Stopped waiting for the task after #{max_retries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher max_retries."
  )
end

#wait_for_app_task(task_id, max_retries = Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES, timeout = Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT, request_options = {}) ⇒ Http::Response

Helper: Wait for an application-level task to be published (completed) for a given task_id.

Parameters:

  • task_id (Integer) —

    the task_id returned in the method response. (required)

  • max_retries (Integer) (defaults to: Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES) —

    the maximum number of retries. (optional, default to Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES)

  • timeout (Proc) (defaults to: Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT) —

    the function to decide how long to wait between retries. (optional, default to Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT)

  • request_options (Hash) (defaults to: {}) —

    the requestOptions to send along with the query, they will be forwarded to the get_task method.

Returns:

Raises:



3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
# File 'lib/algolia/api/search_client.rb', line 3744

def wait_for_app_task(
  task_id,
  max_retries = Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES,
  timeout = Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT,
  request_options = {}
)
  request_options = with_request_id(request_options)
  retries = 0
  while retries < max_retries
    res = get_app_task(task_id, request_options)
    if res.status == "published"
      return res
    end

    retries += 1
    sleep(timeout.call(retries) / 1000.0)
  end

  raise(
    ApiError,
    "Stopped waiting for the task after #{max_retries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher max_retries."
  )
end

#wait_for_task(index_name, task_id, max_retries = Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES, timeout = Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT, request_options = {}) ⇒ Http::Response

Helper: Wait for a task to be published (completed) for a given index_name and task_id.

Parameters:

  • index_name (String) —

    the index_name where the operation was performed. (required)

  • task_id (Integer) —

    the task_id returned in the method response. (required)

  • max_retries (Integer) (defaults to: Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES) —

    the maximum number of retries. (optional, default to Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES)

  • timeout (Proc) (defaults to: Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT) —

    the function to decide how long to wait between retries. (optional, default to Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT)

  • request_options (Hash) (defaults to: {}) —

    the requestOptions to send along with the query, they will be forwarded to the get_task method.

Returns:

Raises:



3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
# File 'lib/algolia/api/search_client.rb', line 3712

def wait_for_task(
  index_name,
  task_id,
  max_retries = Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES,
  timeout = Algolia::ChunkedHelperOptions::DEFAULT_TIMEOUT,
  request_options = {}
)
  request_options = with_request_id(request_options)
  retries = 0
  while retries < max_retries
    res = get_task(index_name, task_id, request_options)
    if res.status == "published"
      return res
    end

    retries += 1
    sleep(timeout.call(retries) / 1000.0)
  end

  raise(
    ApiError,
    "Stopped waiting for the task after #{max_retries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher max_retries."
  )
end