Class: MeiliSearch::Index

Inherits:
HTTPRequest show all
Defined in:
lib/meilisearch/index.rb

Constant Summary

Constants inherited from HTTPRequest

HTTPRequest::DEFAULT_OPTIONS

Instance Attribute Summary collapse

Attributes inherited from HTTPRequest

#headers, #options

Instance Method Summary collapse

Methods inherited from HTTPRequest

#http_delete, #http_get, #http_patch, #http_post, #http_put

Constructor Details

#initialize(index_uid, url, api_key = nil, primary_key = nil, options = {}) ⇒ Index

Returns a new instance of Index.



9
10
11
12
13
# File 'lib/meilisearch/index.rb', line 9

def initialize(index_uid, url, api_key = nil, primary_key = nil, options = {})
  @uid = index_uid
  @primary_key = primary_key
  super(url, api_key, options)
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



7
8
9
# File 'lib/meilisearch/index.rb', line 7

def created_at
  @created_at
end

#primary_keyObject (readonly)

Returns the value of attribute primary_key.



7
8
9
# File 'lib/meilisearch/index.rb', line 7

def primary_key
  @primary_key
end

#uidObject (readonly)

Returns the value of attribute uid.



7
8
9
# File 'lib/meilisearch/index.rb', line 7

def uid
  @uid
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



7
8
9
# File 'lib/meilisearch/index.rb', line 7

def updated_at
  @updated_at
end

Instance Method Details

#add_documents(documents, primary_key = nil) ⇒ Object Also known as: replace_documents, add_or_replace_documents



89
90
91
92
93
94
# File 'lib/meilisearch/index.rb', line 89

def add_documents(documents, primary_key = nil)
  documents = [documents] if documents.is_a?(Hash)
  response = http_post "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact

  Models::Task.new(response, task_endpoint)
end

#add_documents!(documents, primary_key = nil) ⇒ Object Also known as: replace_documents!, add_or_replace_documents!



98
99
100
101
102
103
104
105
# File 'lib/meilisearch/index.rb', line 98

def add_documents!(documents, primary_key = nil)
  Utils.soft_deprecate(
    'Index#add_documents!',
    'index.add_documents(...).await'
  )

  add_documents(documents, primary_key).await
end

#add_documents_csv(documents, primary_key = nil, delimiter = nil) ⇒ Object Also known as: replace_documents_csv, add_or_replace_documents_csv



127
128
129
130
131
132
133
134
135
136
# File 'lib/meilisearch/index.rb', line 127

def add_documents_csv(documents, primary_key = nil, delimiter = nil)
  options = { headers: { 'Content-Type' => 'text/csv' }, convert_body?: false }

  response = http_post "/indexes/#{@uid}/documents", documents, {
    primaryKey: primary_key,
    csvDelimiter: delimiter
  }.compact, options

  Models::Task.new(response, task_endpoint)
end

#add_documents_in_batches(documents, batch_size = 1000, primary_key = nil) ⇒ Object



158
159
160
161
162
# File 'lib/meilisearch/index.rb', line 158

def add_documents_in_batches(documents, batch_size = 1000, primary_key = nil)
  documents.each_slice(batch_size).map do |batch|
    add_documents(batch, primary_key)
  end
end

#add_documents_in_batches!(documents, batch_size = 1000, primary_key = nil) ⇒ Object



164
165
166
167
168
169
170
171
# File 'lib/meilisearch/index.rb', line 164

def add_documents_in_batches!(documents, batch_size = 1000, primary_key = nil)
  Utils.soft_deprecate(
    'Index#add_documents_in_batches!',
    'index.add_documents_in_batches(...).each(&:await)'
  )

  add_documents_in_batches(documents, batch_size, primary_key).each(&:await)
end

#add_documents_json(documents, primary_key = nil) ⇒ Object Also known as: replace_documents_json, add_or_replace_documents_json



109
110
111
112
113
114
# File 'lib/meilisearch/index.rb', line 109

def add_documents_json(documents, primary_key = nil)
  options = { convert_body?: false }
  response = http_post "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact, options

  Models::Task.new(response, task_endpoint)
end

#add_documents_ndjson(documents, primary_key = nil) ⇒ Object Also known as: replace_documents_ndjson, add_or_replace_documents_ndjson



118
119
120
121
122
123
# File 'lib/meilisearch/index.rb', line 118

def add_documents_ndjson(documents, primary_key = nil)
  options = { headers: { 'Content-Type' => 'application/x-ndjson' }, convert_body?: false }
  response = http_post "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact, options

  Models::Task.new(response, task_endpoint)
end

#deleteObject Also known as: delete_index



39
40
41
42
# File 'lib/meilisearch/index.rb', line 39

def delete
  response = http_delete indexes_path(id: @uid)
  Models::Task.new(response, task_endpoint)
end

#delete_all_documentsObject



244
245
246
247
# File 'lib/meilisearch/index.rb', line 244

def delete_all_documents
  response = http_delete "/indexes/#{@uid}/documents"
  Models::Task.new(response, task_endpoint)
end

#delete_all_documents!Object



249
250
251
252
253
254
255
256
# File 'lib/meilisearch/index.rb', line 249

def delete_all_documents!
  Utils.soft_deprecate(
    'Index#delete_all_documents!',
    'index.delete_all_documents(...).await'
  )

  delete_all_documents.await
end

#delete_document(document_id) ⇒ Object Also known as: delete_one_document



222
223
224
225
226
227
228
229
230
231
# File 'lib/meilisearch/index.rb', line 222

def delete_document(document_id)
  if document_id.nil? || document_id.to_s.empty?
    raise MeiliSearch::InvalidDocumentId, 'document_id cannot be empty or nil'
  end

  encode_document = URI.encode_www_form_component(document_id)
  response = http_delete "/indexes/#{@uid}/documents/#{encode_document}"

  Models::Task.new(response, task_endpoint)
end

#delete_document!(document_id) ⇒ Object Also known as: delete_one_document!



234
235
236
237
238
239
240
241
# File 'lib/meilisearch/index.rb', line 234

def delete_document!(document_id)
  Utils.soft_deprecate(
    'Index#delete_document!',
    'index.delete_document(...).await'
  )

  delete_document(document_id).await
end

#delete_documents(options = {}) ⇒ Object Also known as: delete_multiple_documents

Public: Delete documents from an index

options: A Hash or an Array containing documents_ids or a hash with filter:.

filter: - A hash containing a filter that should match documents.
          Available ONLY with Meilisearch v1.2 and newer (optional)

Returns a Task object.



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/meilisearch/index.rb', line 195

def delete_documents(options = {})
  Utils.version_error_handler(__method__) do
    response = if options.is_a?(Hash) && options.key?(:filter)
                 http_post "/indexes/#{@uid}/documents/delete", options
               else
                 # backwards compatibility:
                 # expect to be a array or/number/string to send alongside as documents_ids.
                 options = [options] unless options.is_a?(Array)

                 http_post "/indexes/#{@uid}/documents/delete-batch", options
               end

    Models::Task.new(response, task_endpoint)
  end
end

#delete_documents!(documents_ids) ⇒ Object Also known as: delete_multiple_documents!



212
213
214
215
216
217
218
219
# File 'lib/meilisearch/index.rb', line 212

def delete_documents!(documents_ids)
  Utils.soft_deprecate(
    'Index#delete_documents!',
    'index.delete_documents(...).await'
  )

  delete_documents(documents_ids).await
end

#dictionaryObject

SETTINGS - DICTIONARY



545
546
547
# File 'lib/meilisearch/index.rb', line 545

def dictionary
  http_get("/indexes/#{@uid}/settings/dictionary")
end

#displayed_attributesObject Also known as: get_displayed_attributes

SETTINGS - DISPLAYED ATTRIBUTES



439
440
441
# File 'lib/meilisearch/index.rb', line 439

def displayed_attributes
  http_get "/indexes/#{@uid}/settings/displayed-attributes"
end

#distinct_attributeObject Also known as: get_distinct_attribute

SETTINGS - DISTINCT ATTRIBUTE



403
404
405
# File 'lib/meilisearch/index.rb', line 403

def distinct_attribute
  http_get "/indexes/#{@uid}/settings/distinct-attribute"
end

#document(document_id, fields: nil) ⇒ Object Also known as: get_document, get_one_document

DOCUMENTS



59
60
61
62
63
64
# File 'lib/meilisearch/index.rb', line 59

def document(document_id, fields: nil)
  encode_document = URI.encode_www_form_component(document_id)
  body = { fields: fields&.join(',') }.compact

  http_get("/indexes/#{@uid}/documents/#{encode_document}", body)
end

#documents(options = {}) ⇒ Object Also known as: get_documents

Public: Retrieve documents from a index.

options - The hash options used to refine the selection (default: {}):

:limit  - Number of documents to return (optional).
:offset - Number of documents to skip (optional).
:fields - Array of document attributes to show (optional).
:filter - Filter queries by an attribute's value.
          Available ONLY with Meilisearch v1.2 and newer (optional).

Returns the documents results object.



78
79
80
81
82
83
84
85
86
# File 'lib/meilisearch/index.rb', line 78

def documents(options = {})
  Utils.version_error_handler(__method__) do
    if options.key?(:filter)
      http_post "/indexes/#{@uid}/documents/fetch", Utils.filter(options, [:limit, :offset, :fields, :filter])
    else
      http_get "/indexes/#{@uid}/documents", Utils.parse_query(options, [:limit, :offset, :fields])
    end
  end
end

#facet_search(name, query = '', **options) ⇒ Object

FACET SEARCH



284
285
286
287
288
289
# File 'lib/meilisearch/index.rb', line 284

def facet_search(name, query = '', **options)
  options.merge!(facet_name: name, facet_query: query)
  options = Utils.transform_attributes(options)

  http_post("/indexes/#{@uid}/facet-search", options)
end

#facetingObject Also known as: get_faceting



526
527
528
# File 'lib/meilisearch/index.rb', line 526

def faceting
  http_get("/indexes/#{@uid}/settings/faceting")
end

#fetch_infoObject



15
16
17
18
19
# File 'lib/meilisearch/index.rb', line 15

def fetch_info
  index_hash = http_get indexes_path(id: @uid)
  set_base_properties index_hash
  self
end

#fetch_primary_keyObject Also known as: get_primary_key



21
22
23
# File 'lib/meilisearch/index.rb', line 21

def fetch_primary_key
  fetch_info.primary_key
end

#fetch_raw_infoObject



26
27
28
29
30
# File 'lib/meilisearch/index.rb', line 26

def fetch_raw_info
  index_hash = http_get indexes_path(id: @uid)
  set_base_properties index_hash
  index_hash
end

#field_distributionObject



324
325
326
# File 'lib/meilisearch/index.rb', line 324

def field_distribution
  stats['fieldDistribution']
end

#filterable_attributesObject Also known as: get_filterable_attributes

SETTINGS - FILTERABLE ATTRIBUTES



457
458
459
# File 'lib/meilisearch/index.rb', line 457

def filterable_attributes
  http_get "/indexes/#{@uid}/settings/filterable-attributes"
end

#indexing?Boolean

Returns:

  • (Boolean)


320
321
322
# File 'lib/meilisearch/index.rb', line 320

def indexing?
  stats['isIndexing']
end

#non_separator_tokensObject

SETTINGS - NON SEPARATOR TOKENS



578
579
580
# File 'lib/meilisearch/index.rb', line 578

def non_separator_tokens
  http_get("/indexes/#{@uid}/settings/non-separator-tokens")
end

#number_of_documentsObject



316
317
318
# File 'lib/meilisearch/index.rb', line 316

def number_of_documents
  stats['numberOfDocuments']
end

#paginationObject Also known as: get_pagination

SETTINGS - PAGINATION



493
494
495
# File 'lib/meilisearch/index.rb', line 493

def pagination
  http_get("/indexes/#{@uid}/settings/pagination")
end

#proximity_precisionObject

SETTINGS - PROXIMITY PRECISION



595
596
597
# File 'lib/meilisearch/index.rb', line 595

def proximity_precision
  http_get("/indexes/#{@uid}/settings/proximity-precision")
end

#ranking_rulesObject Also known as: get_ranking_rules

SETTINGS - RANKING RULES



348
349
350
# File 'lib/meilisearch/index.rb', line 348

def ranking_rules
  http_get "/indexes/#{@uid}/settings/ranking-rules"
end

#reset_dictionaryObject



555
556
557
558
# File 'lib/meilisearch/index.rb', line 555

def reset_dictionary
  response = http_delete("/indexes/#{@uid}/settings/dictionary")
  Models::Task.new(response, task_endpoint)
end

#reset_displayed_attributesObject



450
451
452
453
# File 'lib/meilisearch/index.rb', line 450

def reset_displayed_attributes
  response = http_delete "/indexes/#{@uid}/settings/displayed-attributes"
  Models::Task.new(response, task_endpoint)
end

#reset_distinct_attributeObject



414
415
416
417
# File 'lib/meilisearch/index.rb', line 414

def reset_distinct_attribute
  response = http_delete "/indexes/#{@uid}/settings/distinct-attribute"
  Models::Task.new(response, task_endpoint)
end

#reset_facetingObject



538
539
540
541
# File 'lib/meilisearch/index.rb', line 538

def reset_faceting
  response = http_delete("/indexes/#{@uid}/settings/faceting")
  Models::Task.new(response, task_endpoint)
end

#reset_filterable_attributesObject



468
469
470
471
# File 'lib/meilisearch/index.rb', line 468

def reset_filterable_attributes
  response = http_delete "/indexes/#{@uid}/settings/filterable-attributes"
  Models::Task.new(response, task_endpoint)
end

#reset_non_separator_tokensObject



588
589
590
591
# File 'lib/meilisearch/index.rb', line 588

def reset_non_separator_tokens
  response = http_delete("/indexes/#{@uid}/settings/non-separator-tokens")
  Models::Task.new(response, task_endpoint)
end

#reset_paginationObject



504
505
506
507
# File 'lib/meilisearch/index.rb', line 504

def reset_pagination
  response = http_delete "/indexes/#{@uid}/settings/pagination"
  Models::Task.new(response, task_endpoint)
end

#reset_proximity_precisionObject



603
604
605
# File 'lib/meilisearch/index.rb', line 603

def reset_proximity_precision
  http_delete("/indexes/#{@uid}/settings/proximity-precision")
end

#reset_ranking_rulesObject



359
360
361
362
# File 'lib/meilisearch/index.rb', line 359

def reset_ranking_rules
  response = http_delete "/indexes/#{@uid}/settings/ranking-rules"
  Models::Task.new(response, task_endpoint)
end

#reset_search_cutoff_msObject



617
618
619
# File 'lib/meilisearch/index.rb', line 617

def reset_search_cutoff_ms
  http_delete("/indexes/#{@uid}/settings/search-cutoff-ms")
end

#reset_searchable_attributesObject



432
433
434
435
# File 'lib/meilisearch/index.rb', line 432

def reset_searchable_attributes
  response = http_delete "/indexes/#{@uid}/settings/searchable-attributes"
  Models::Task.new(response, task_endpoint)
end

#reset_separator_tokensObject



571
572
573
574
# File 'lib/meilisearch/index.rb', line 571

def reset_separator_tokens
  response = http_delete("/indexes/#{@uid}/settings/separator-tokens")
  Models::Task.new(response, task_endpoint)
end

#reset_settingsObject



341
342
343
344
# File 'lib/meilisearch/index.rb', line 341

def reset_settings
  response = http_delete "/indexes/#{@uid}/settings"
  Models::Task.new(response, task_endpoint)
end

#reset_sortable_attributesObject



486
487
488
489
# File 'lib/meilisearch/index.rb', line 486

def reset_sortable_attributes
  response = http_delete "/indexes/#{@uid}/settings/sortable-attributes"
  Models::Task.new(response, task_endpoint)
end

#reset_stop_wordsObject



396
397
398
399
# File 'lib/meilisearch/index.rb', line 396

def reset_stop_words
  response = http_delete "/indexes/#{@uid}/settings/stop-words"
  Models::Task.new(response, task_endpoint)
end

#reset_synonymsObject



377
378
379
380
# File 'lib/meilisearch/index.rb', line 377

def reset_synonyms
  response = http_delete "/indexes/#{@uid}/settings/synonyms"
  Models::Task.new(response, task_endpoint)
end

#reset_typo_toleranceObject



521
522
523
524
# File 'lib/meilisearch/index.rb', line 521

def reset_typo_tolerance
  response = http_delete("/indexes/#{@uid}/settings/typo-tolerance")
  Models::Task.new(response, task_endpoint)
end

#search(query, options = {}) ⇒ Object

options: A Hash

show_ranking_score - To see the ranking scores for returned documents
attributes_to_search_on - Customize attributes to search on at search time.


263
264
265
266
267
268
269
270
271
272
# File 'lib/meilisearch/index.rb', line 263

def search(query, options = {})
  attributes = { q: query.to_s }.merge(options.compact)

  parsed_options = Utils.transform_attributes(attributes)
  response = http_post "/indexes/#{@uid}/search", parsed_options

  response['nbHits'] ||= response['estimatedTotalHits'] unless response.key?('totalPages')

  response
end

#search_cutoff_msObject

SETTINGS - SEARCH CUTOFF MS



609
610
611
# File 'lib/meilisearch/index.rb', line 609

def search_cutoff_ms
  http_get("/indexes/#{@uid}/settings/search-cutoff-ms")
end

#search_similar_documents(document_id, **options) ⇒ Object

document_id: Identifier of the target document



275
276
277
278
279
280
# File 'lib/meilisearch/index.rb', line 275

def search_similar_documents(document_id, **options)
  options.merge!(id: document_id)
  options = Utils.transform_attributes(options)

  http_post("/indexes/#{@uid}/similar", options)
end

#searchable_attributesObject Also known as: get_searchable_attributes

SETTINGS - SEARCHABLE ATTRIBUTES



421
422
423
# File 'lib/meilisearch/index.rb', line 421

def searchable_attributes
  http_get "/indexes/#{@uid}/settings/searchable-attributes"
end

#separator_tokensObject

SETTINGS - SEPARATOR TOKENS



561
562
563
# File 'lib/meilisearch/index.rb', line 561

def separator_tokens
  http_get("/indexes/#{@uid}/settings/separator-tokens")
end

#settingsObject Also known as: get_settings

SETTINGS - GENERAL



330
331
332
# File 'lib/meilisearch/index.rb', line 330

def settings
  http_get "/indexes/#{@uid}/settings"
end

#sortable_attributesObject Also known as: get_sortable_attributes

SETTINGS - SORTABLE ATTRIBUTES



475
476
477
# File 'lib/meilisearch/index.rb', line 475

def sortable_attributes
  http_get "/indexes/#{@uid}/settings/sortable-attributes"
end

#statsObject

STATS



312
313
314
# File 'lib/meilisearch/index.rb', line 312

def stats
  http_get "/indexes/#{@uid}/stats"
end

#stop_wordsObject Also known as: get_stop_words

SETTINGS - STOP-WORDS



384
385
386
# File 'lib/meilisearch/index.rb', line 384

def stop_words
  http_get "/indexes/#{@uid}/settings/stop-words"
end

#synonymsObject Also known as: get_synonyms

SETTINGS - SYNONYMS



366
367
368
# File 'lib/meilisearch/index.rb', line 366

def synonyms
  http_get "/indexes/#{@uid}/settings/synonyms"
end

#task(task_uid) ⇒ Object



298
299
300
# File 'lib/meilisearch/index.rb', line 298

def task(task_uid)
  task_endpoint.index_task(task_uid)
end

#tasksObject



302
303
304
# File 'lib/meilisearch/index.rb', line 302

def tasks
  task_endpoint.index_tasks(@uid)
end

#typo_toleranceObject Also known as: get_typo_tolerance



509
510
511
# File 'lib/meilisearch/index.rb', line 509

def typo_tolerance
  http_get("/indexes/#{@uid}/settings/typo-tolerance")
end

#update(body) ⇒ Object Also known as: update_index



32
33
34
35
# File 'lib/meilisearch/index.rb', line 32

def update(body)
  response = http_patch indexes_path(id: @uid), Utils.transform_attributes(body)
  Models::Task.new(response, task_endpoint)
end

#update_dictionary(dictionary_attributes) ⇒ Object



549
550
551
552
553
# File 'lib/meilisearch/index.rb', line 549

def update_dictionary(dictionary_attributes)
  attributes = Utils.transform_attributes(dictionary_attributes)
  response = http_put("/indexes/#{@uid}/settings/dictionary", attributes)
  Models::Task.new(response, task_endpoint)
end

#update_displayed_attributes(displayed_attributes) ⇒ Object Also known as: displayed_attributes=



444
445
446
447
# File 'lib/meilisearch/index.rb', line 444

def update_displayed_attributes(displayed_attributes)
  response = http_put "/indexes/#{@uid}/settings/displayed-attributes", displayed_attributes
  Models::Task.new(response, task_endpoint)
end

#update_distinct_attribute(distinct_attribute) ⇒ Object Also known as: distinct_attribute=



408
409
410
411
# File 'lib/meilisearch/index.rb', line 408

def update_distinct_attribute(distinct_attribute)
  response = http_put "/indexes/#{@uid}/settings/distinct-attribute", distinct_attribute
  Models::Task.new(response, task_endpoint)
end

#update_documents(documents, primary_key = nil) ⇒ Object Also known as: add_or_update_documents



140
141
142
143
144
145
# File 'lib/meilisearch/index.rb', line 140

def update_documents(documents, primary_key = nil)
  documents = [documents] if documents.is_a?(Hash)
  response = http_put "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact

  Models::Task.new(response, task_endpoint)
end

#update_documents!(documents, primary_key = nil) ⇒ Object Also known as: add_or_update_documents!



148
149
150
151
152
153
154
155
# File 'lib/meilisearch/index.rb', line 148

def update_documents!(documents, primary_key = nil)
  Utils.soft_deprecate(
    'Index#update_documents!',
    'index.update_documents(...).await'
  )

  update_documents(documents, primary_key).await
end

#update_documents_in_batches(documents, batch_size = 1000, primary_key = nil) ⇒ Object



173
174
175
176
177
# File 'lib/meilisearch/index.rb', line 173

def update_documents_in_batches(documents, batch_size = 1000, primary_key = nil)
  documents.each_slice(batch_size).map do |batch|
    update_documents(batch, primary_key)
  end
end

#update_documents_in_batches!(documents, batch_size = 1000, primary_key = nil) ⇒ Object



179
180
181
182
183
184
185
186
# File 'lib/meilisearch/index.rb', line 179

def update_documents_in_batches!(documents, batch_size = 1000, primary_key = nil)
  Utils.soft_deprecate(
    'Index#update_documents_in_batches!',
    'index.update_documents_in_batches(...).each(&:await)'
  )

  update_documents_in_batches(documents, batch_size, primary_key).each(&:await)
end

#update_faceting(faceting_attributes) ⇒ Object Also known as: faceting=



531
532
533
534
535
# File 'lib/meilisearch/index.rb', line 531

def update_faceting(faceting_attributes)
  attributes = Utils.transform_attributes(faceting_attributes)
  response = http_patch("/indexes/#{@uid}/settings/faceting", attributes)
  Models::Task.new(response, task_endpoint)
end

#update_filterable_attributes(filterable_attributes) ⇒ Object Also known as: filterable_attributes=



462
463
464
465
# File 'lib/meilisearch/index.rb', line 462

def update_filterable_attributes(filterable_attributes)
  response = http_put "/indexes/#{@uid}/settings/filterable-attributes", filterable_attributes
  Models::Task.new(response, task_endpoint)
end

#update_non_separator_tokens(non_separator_tokens_attributes) ⇒ Object



582
583
584
585
586
# File 'lib/meilisearch/index.rb', line 582

def update_non_separator_tokens(non_separator_tokens_attributes)
  attributes = Utils.transform_attributes(non_separator_tokens_attributes)
  response = http_put("/indexes/#{@uid}/settings/non-separator-tokens", attributes)
  Models::Task.new(response, task_endpoint)
end

#update_pagination(pagination) ⇒ Object



498
499
500
501
# File 'lib/meilisearch/index.rb', line 498

def update_pagination(pagination)
  response = http_patch "/indexes/#{@uid}/settings/pagination", pagination
  Models::Task.new(response, task_endpoint)
end

#update_proximity_precision(proximity_precision_attribute) ⇒ Object



599
600
601
# File 'lib/meilisearch/index.rb', line 599

def update_proximity_precision(proximity_precision_attribute)
  http_put("/indexes/#{@uid}/settings/proximity-precision", proximity_precision_attribute)
end

#update_ranking_rules(ranking_rules) ⇒ Object Also known as: ranking_rules=



353
354
355
356
# File 'lib/meilisearch/index.rb', line 353

def update_ranking_rules(ranking_rules)
  response = http_put "/indexes/#{@uid}/settings/ranking-rules", ranking_rules
  Models::Task.new(response, task_endpoint)
end

#update_search_cutoff_ms(search_cutoff_ms_attribute) ⇒ Object



613
614
615
# File 'lib/meilisearch/index.rb', line 613

def update_search_cutoff_ms(search_cutoff_ms_attribute)
  http_put("/indexes/#{@uid}/settings/search-cutoff-ms", search_cutoff_ms_attribute)
end

#update_searchable_attributes(searchable_attributes) ⇒ Object Also known as: searchable_attributes=



426
427
428
429
# File 'lib/meilisearch/index.rb', line 426

def update_searchable_attributes(searchable_attributes)
  response = http_put "/indexes/#{@uid}/settings/searchable-attributes", searchable_attributes
  Models::Task.new(response, task_endpoint)
end

#update_separator_tokens(separator_tokens_attributes) ⇒ Object



565
566
567
568
569
# File 'lib/meilisearch/index.rb', line 565

def update_separator_tokens(separator_tokens_attributes)
  attributes = Utils.transform_attributes(separator_tokens_attributes)
  response = http_put("/indexes/#{@uid}/settings/separator-tokens", attributes)
  Models::Task.new(response, task_endpoint)
end

#update_settings(settings) ⇒ Object Also known as: settings=



335
336
337
338
# File 'lib/meilisearch/index.rb', line 335

def update_settings(settings)
  response = http_patch "/indexes/#{@uid}/settings", Utils.transform_attributes(settings)
  Models::Task.new(response, task_endpoint)
end

#update_sortable_attributes(sortable_attributes) ⇒ Object Also known as: sortable_attributes=, pagination=



480
481
482
483
# File 'lib/meilisearch/index.rb', line 480

def update_sortable_attributes(sortable_attributes)
  response = http_put "/indexes/#{@uid}/settings/sortable-attributes", sortable_attributes
  Models::Task.new(response, task_endpoint)
end

#update_stop_words(stop_words) ⇒ Object Also known as: stop_words=



389
390
391
392
393
# File 'lib/meilisearch/index.rb', line 389

def update_stop_words(stop_words)
  body = stop_words.nil? || stop_words.is_a?(Array) ? stop_words : [stop_words]
  response = http_put "/indexes/#{@uid}/settings/stop-words", body
  Models::Task.new(response, task_endpoint)
end

#update_synonyms(synonyms) ⇒ Object Also known as: synonyms=



371
372
373
374
# File 'lib/meilisearch/index.rb', line 371

def update_synonyms(synonyms)
  response = http_put "/indexes/#{@uid}/settings/synonyms", synonyms
  Models::Task.new(response, task_endpoint)
end

#update_typo_tolerance(typo_tolerance_attributes) ⇒ Object Also known as: typo_tolerance=



514
515
516
517
518
# File 'lib/meilisearch/index.rb', line 514

def update_typo_tolerance(typo_tolerance_attributes)
  attributes = Utils.transform_attributes(typo_tolerance_attributes)
  response = http_patch("/indexes/#{@uid}/settings/typo-tolerance", attributes)
  Models::Task.new(response, task_endpoint)
end

#wait_for_task(task_uid, timeout_in_ms = 5000, interval_in_ms = 50) ⇒ Object



306
307
308
# File 'lib/meilisearch/index.rb', line 306

def wait_for_task(task_uid, timeout_in_ms = 5000, interval_in_ms = 50)
  task_endpoint.wait_for_task(task_uid, timeout_in_ms, interval_in_ms)
end