Class: MeiliSearch::Index
Constant Summary
Constants inherited
from HTTPRequest
HTTPRequest::DEFAULT_OPTIONS
Instance Attribute Summary collapse
Attributes inherited from HTTPRequest
#headers, #options
Instance Method Summary
collapse
-
#add_documents(documents, primary_key = nil) ⇒ Object
(also: #replace_documents, #add_or_replace_documents)
-
#add_documents!(documents, primary_key = nil) ⇒ Object
(also: #replace_documents!, #add_or_replace_documents!)
-
#add_documents_csv(documents, primary_key = nil, delimiter = nil) ⇒ Object
(also: #replace_documents_csv, #add_or_replace_documents_csv)
-
#add_documents_in_batches(documents, batch_size = 1000, primary_key = nil) ⇒ Object
-
#add_documents_in_batches!(documents, batch_size = 1000, primary_key = nil) ⇒ Object
-
#add_documents_json(documents, primary_key = nil) ⇒ Object
(also: #replace_documents_json, #add_or_replace_documents_json)
-
#add_documents_ndjson(documents, primary_key = nil) ⇒ Object
(also: #replace_documents_ndjson, #add_or_replace_documents_ndjson)
-
#delete ⇒ Object
(also: #delete_index)
-
#delete_all_documents ⇒ Object
-
#delete_all_documents! ⇒ Object
-
#delete_document(document_id) ⇒ Object
(also: #delete_one_document)
-
#delete_document!(document_id) ⇒ Object
(also: #delete_one_document!)
-
#delete_documents(options = {}) ⇒ Object
(also: #delete_multiple_documents)
Public: Delete documents from an index.
-
#delete_documents!(documents_ids) ⇒ Object
(also: #delete_multiple_documents!)
-
#dictionary ⇒ Object
-
#displayed_attributes ⇒ Object
(also: #get_displayed_attributes)
SETTINGS - DISPLAYED ATTRIBUTES.
-
#distinct_attribute ⇒ Object
(also: #get_distinct_attribute)
SETTINGS - DINSTINCT ATTRIBUTE.
-
#document(document_id, fields: nil) ⇒ Object
(also: #get_document, #get_one_document)
-
#documents(options = {}) ⇒ Object
(also: #get_documents)
Public: Retrieve documents from a index.
-
#facet_search(name, query = '', **options) ⇒ Object
-
#faceting ⇒ Object
(also: #get_faceting)
-
#fetch_info ⇒ Object
-
#fetch_primary_key ⇒ Object
(also: #get_primary_key)
-
#fetch_raw_info ⇒ Object
-
#field_distribution ⇒ Object
-
#filterable_attributes ⇒ Object
(also: #get_filterable_attributes)
SETTINGS - FILTERABLE ATTRIBUTES.
-
#indexing? ⇒ Boolean
-
#initialize(index_uid, url, api_key = nil, primary_key = nil, options = {}) ⇒ Index
constructor
-
#non_separator_tokens ⇒ Object
SETTINGS - NON SEPARATOR TOKENS.
-
#number_of_documents ⇒ Object
-
#pagination ⇒ Object
(also: #get_pagination)
-
#proximity_precision ⇒ Object
SETTINGS - PROXIMITY PRECISION.
-
#ranking_rules ⇒ Object
(also: #get_ranking_rules)
SETTINGS - RANKING RULES.
-
#reset_dictionary ⇒ Object
-
#reset_displayed_attributes ⇒ Object
-
#reset_distinct_attribute ⇒ Object
-
#reset_faceting ⇒ Object
-
#reset_filterable_attributes ⇒ Object
-
#reset_non_separator_tokens ⇒ Object
-
#reset_pagination ⇒ Object
-
#reset_proximity_precision ⇒ Object
-
#reset_ranking_rules ⇒ Object
-
#reset_searchable_attributes ⇒ Object
-
#reset_separator_tokens ⇒ Object
-
#reset_settings ⇒ Object
-
#reset_sortable_attributes ⇒ Object
-
#reset_stop_words ⇒ Object
-
#reset_synonyms ⇒ Object
-
#reset_typo_tolerance ⇒ Object
-
#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.
-
#searchable_attributes ⇒ Object
(also: #get_searchable_attributes)
SETTINGS - SEARCHABLE ATTRIBUTES.
-
#separator_tokens ⇒ Object
SETTINGS - SEPARATOR TOKENS.
-
#settings ⇒ Object
(also: #get_settings)
-
#sortable_attributes ⇒ Object
(also: #get_sortable_attributes)
SETTINGS - SORTABLE ATTRIBUTES.
-
#stats ⇒ Object
-
#stop_words ⇒ Object
(also: #get_stop_words)
-
#synonyms ⇒ Object
(also: #get_synonyms)
-
#task(task_uid) ⇒ Object
-
#tasks ⇒ Object
-
#typo_tolerance ⇒ Object
(also: #get_typo_tolerance)
-
#update(body) ⇒ Object
(also: #update_index)
-
#update_dictionary(dictionary_attributes) ⇒ Object
-
#update_displayed_attributes(displayed_attributes) ⇒ Object
(also: #displayed_attributes=)
-
#update_distinct_attribute(distinct_attribute) ⇒ Object
(also: #distinct_attribute=)
-
#update_documents(documents, primary_key = nil) ⇒ Object
(also: #add_or_update_documents)
-
#update_documents!(documents, primary_key = nil) ⇒ Object
(also: #add_or_update_documents!)
-
#update_documents_in_batches(documents, batch_size = 1000, primary_key = nil) ⇒ Object
-
#update_documents_in_batches!(documents, batch_size = 1000, primary_key = nil) ⇒ Object
-
#update_faceting(faceting_attributes) ⇒ Object
(also: #faceting=)
-
#update_filterable_attributes(filterable_attributes) ⇒ Object
(also: #filterable_attributes=)
-
#update_non_separator_tokens(non_separator_tokens_attributes) ⇒ Object
-
#update_pagination(pagination) ⇒ Object
-
#update_proximity_precision(proximity_precision_attribute) ⇒ Object
-
#update_ranking_rules(ranking_rules) ⇒ Object
(also: #ranking_rules=)
-
#update_searchable_attributes(searchable_attributes) ⇒ Object
(also: #searchable_attributes=)
-
#update_separator_tokens(separator_tokens_attributes) ⇒ Object
-
#update_settings(settings) ⇒ Object
(also: #settings=)
-
#update_sortable_attributes(sortable_attributes) ⇒ Object
(also: #sortable_attributes=, #pagination=)
-
#update_stop_words(stop_words) ⇒ Object
(also: #stop_words=)
-
#update_synonyms(synonyms) ⇒ Object
(also: #synonyms=)
-
#update_typo_tolerance(typo_tolerance_attributes) ⇒ Object
(also: #typo_tolerance=)
-
#wait_for_task(task_uid, timeout_in_ms = 5000, interval_in_ms = 50) ⇒ Object
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_at ⇒ Object
Returns the value of attribute created_at.
7
8
9
|
# File 'lib/meilisearch/index.rb', line 7
def created_at
@created_at
end
|
#primary_key ⇒ Object
Returns the value of attribute primary_key.
7
8
9
|
# File 'lib/meilisearch/index.rb', line 7
def primary_key
@primary_key
end
|
#uid ⇒ Object
Returns the value of attribute uid.
7
8
9
|
# File 'lib/meilisearch/index.rb', line 7
def uid
@uid
end
|
#updated_at ⇒ Object
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
|
#delete ⇒ Object
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_documents ⇒ Object
240
241
242
243
|
# File 'lib/meilisearch/index.rb', line 240
def delete_all_documents
response = http_delete "/indexes/#{@uid}/documents"
Models::Task.new(response, task_endpoint)
end
|
#delete_all_documents! ⇒ Object
245
246
247
248
249
250
251
252
|
# File 'lib/meilisearch/index.rb', line 245
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
|
# File 'lib/meilisearch/index.rb', line 222
def delete_document(document_id)
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!
230
231
232
233
234
235
236
237
|
# File 'lib/meilisearch/index.rb', line 230
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
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
|
#dictionary ⇒ Object
533
534
535
|
# File 'lib/meilisearch/index.rb', line 533
def dictionary
http_get("/indexes/#{@uid}/settings/dictionary")
end
|
#displayed_attributes ⇒ Object
Also known as:
get_displayed_attributes
SETTINGS - DISPLAYED ATTRIBUTES
427
428
429
|
# File 'lib/meilisearch/index.rb', line 427
def displayed_attributes
http_get "/indexes/#{@uid}/settings/displayed-attributes"
end
|
#distinct_attribute ⇒ Object
Also known as:
get_distinct_attribute
SETTINGS - DINSTINCT ATTRIBUTE
391
392
393
|
# File 'lib/meilisearch/index.rb', line 391
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
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
272
273
274
275
276
277
|
# File 'lib/meilisearch/index.rb', line 272
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
|
#faceting ⇒ Object
Also known as:
get_faceting
514
515
516
|
# File 'lib/meilisearch/index.rb', line 514
def faceting
http_get("/indexes/#{@uid}/settings/faceting")
end
|
#fetch_info ⇒ Object
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_key ⇒ Object
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_info ⇒ Object
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_distribution ⇒ Object
312
313
314
|
# File 'lib/meilisearch/index.rb', line 312
def field_distribution
stats['fieldDistribution']
end
|
#filterable_attributes ⇒ Object
Also known as:
get_filterable_attributes
SETTINGS - FILTERABLE ATTRIBUTES
445
446
447
|
# File 'lib/meilisearch/index.rb', line 445
def filterable_attributes
http_get "/indexes/#{@uid}/settings/filterable-attributes"
end
|
#indexing? ⇒ Boolean
308
309
310
|
# File 'lib/meilisearch/index.rb', line 308
def indexing?
stats['isIndexing']
end
|
#non_separator_tokens ⇒ Object
SETTINGS - NON SEPARATOR TOKENS
566
567
568
|
# File 'lib/meilisearch/index.rb', line 566
def non_separator_tokens
http_get("/indexes/#{@uid}/settings/non-separator-tokens")
end
|
#number_of_documents ⇒ Object
304
305
306
|
# File 'lib/meilisearch/index.rb', line 304
def number_of_documents
stats['numberOfDocuments']
end
|
481
482
483
|
# File 'lib/meilisearch/index.rb', line 481
def
http_get("/indexes/#{@uid}/settings/pagination")
end
|
#proximity_precision ⇒ Object
SETTINGS - PROXIMITY PRECISION
583
584
585
|
# File 'lib/meilisearch/index.rb', line 583
def proximity_precision
http_get("/indexes/#{@uid}/settings/proximity-precision")
end
|
#ranking_rules ⇒ Object
Also known as:
get_ranking_rules
336
337
338
|
# File 'lib/meilisearch/index.rb', line 336
def ranking_rules
http_get "/indexes/#{@uid}/settings/ranking-rules"
end
|
#reset_dictionary ⇒ Object
543
544
545
546
|
# File 'lib/meilisearch/index.rb', line 543
def reset_dictionary
response = http_delete("/indexes/#{@uid}/settings/dictionary")
Models::Task.new(response, task_endpoint)
end
|
#reset_displayed_attributes ⇒ Object
438
439
440
441
|
# File 'lib/meilisearch/index.rb', line 438
def reset_displayed_attributes
response = http_delete "/indexes/#{@uid}/settings/displayed-attributes"
Models::Task.new(response, task_endpoint)
end
|
#reset_distinct_attribute ⇒ Object
402
403
404
405
|
# File 'lib/meilisearch/index.rb', line 402
def reset_distinct_attribute
response = http_delete "/indexes/#{@uid}/settings/distinct-attribute"
Models::Task.new(response, task_endpoint)
end
|
#reset_faceting ⇒ Object
526
527
528
529
|
# File 'lib/meilisearch/index.rb', line 526
def reset_faceting
response = http_delete("/indexes/#{@uid}/settings/faceting")
Models::Task.new(response, task_endpoint)
end
|
#reset_filterable_attributes ⇒ Object
456
457
458
459
|
# File 'lib/meilisearch/index.rb', line 456
def reset_filterable_attributes
response = http_delete "/indexes/#{@uid}/settings/filterable-attributes"
Models::Task.new(response, task_endpoint)
end
|
#reset_non_separator_tokens ⇒ Object
576
577
578
579
|
# File 'lib/meilisearch/index.rb', line 576
def reset_non_separator_tokens
response = http_delete("/indexes/#{@uid}/settings/non-separator-tokens")
Models::Task.new(response, task_endpoint)
end
|
492
493
494
495
|
# File 'lib/meilisearch/index.rb', line 492
def
response = http_delete "/indexes/#{@uid}/settings/pagination"
Models::Task.new(response, task_endpoint)
end
|
#reset_proximity_precision ⇒ Object
591
592
593
|
# File 'lib/meilisearch/index.rb', line 591
def reset_proximity_precision
http_delete("/indexes/#{@uid}/settings/proximity-precision")
end
|
#reset_ranking_rules ⇒ Object
347
348
349
350
|
# File 'lib/meilisearch/index.rb', line 347
def reset_ranking_rules
response = http_delete "/indexes/#{@uid}/settings/ranking-rules"
Models::Task.new(response, task_endpoint)
end
|
#reset_searchable_attributes ⇒ Object
420
421
422
423
|
# File 'lib/meilisearch/index.rb', line 420
def reset_searchable_attributes
response = http_delete "/indexes/#{@uid}/settings/searchable-attributes"
Models::Task.new(response, task_endpoint)
end
|
#reset_separator_tokens ⇒ Object
559
560
561
562
|
# File 'lib/meilisearch/index.rb', line 559
def reset_separator_tokens
response = http_delete("/indexes/#{@uid}/settings/separator-tokens")
Models::Task.new(response, task_endpoint)
end
|
#reset_settings ⇒ Object
329
330
331
332
|
# File 'lib/meilisearch/index.rb', line 329
def reset_settings
response = http_delete "/indexes/#{@uid}/settings"
Models::Task.new(response, task_endpoint)
end
|
#reset_sortable_attributes ⇒ Object
474
475
476
477
|
# File 'lib/meilisearch/index.rb', line 474
def reset_sortable_attributes
response = http_delete "/indexes/#{@uid}/settings/sortable-attributes"
Models::Task.new(response, task_endpoint)
end
|
#reset_stop_words ⇒ Object
384
385
386
387
|
# File 'lib/meilisearch/index.rb', line 384
def reset_stop_words
response = http_delete "/indexes/#{@uid}/settings/stop-words"
Models::Task.new(response, task_endpoint)
end
|
#reset_synonyms ⇒ Object
365
366
367
368
|
# File 'lib/meilisearch/index.rb', line 365
def reset_synonyms
response = http_delete "/indexes/#{@uid}/settings/synonyms"
Models::Task.new(response, task_endpoint)
end
|
#reset_typo_tolerance ⇒ Object
509
510
511
512
|
# File 'lib/meilisearch/index.rb', line 509
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.
259
260
261
262
263
264
265
266
267
268
|
# File 'lib/meilisearch/index.rb', line 259
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
|
#searchable_attributes ⇒ Object
Also known as:
get_searchable_attributes
SETTINGS - SEARCHABLE ATTRIBUTES
409
410
411
|
# File 'lib/meilisearch/index.rb', line 409
def searchable_attributes
http_get "/indexes/#{@uid}/settings/searchable-attributes"
end
|
#separator_tokens ⇒ Object
SETTINGS - SEPARATOR TOKENS
549
550
551
|
# File 'lib/meilisearch/index.rb', line 549
def separator_tokens
http_get("/indexes/#{@uid}/settings/separator-tokens")
end
|
#settings ⇒ Object
Also known as:
get_settings
318
319
320
|
# File 'lib/meilisearch/index.rb', line 318
def settings
http_get "/indexes/#{@uid}/settings"
end
|
#sortable_attributes ⇒ Object
Also known as:
get_sortable_attributes
SETTINGS - SORTABLE ATTRIBUTES
463
464
465
|
# File 'lib/meilisearch/index.rb', line 463
def sortable_attributes
http_get "/indexes/#{@uid}/settings/sortable-attributes"
end
|
#stats ⇒ Object
300
301
302
|
# File 'lib/meilisearch/index.rb', line 300
def stats
http_get "/indexes/#{@uid}/stats"
end
|
#stop_words ⇒ Object
Also known as:
get_stop_words
372
373
374
|
# File 'lib/meilisearch/index.rb', line 372
def stop_words
http_get "/indexes/#{@uid}/settings/stop-words"
end
|
#synonyms ⇒ Object
Also known as:
get_synonyms
354
355
356
|
# File 'lib/meilisearch/index.rb', line 354
def synonyms
http_get "/indexes/#{@uid}/settings/synonyms"
end
|
#task(task_uid) ⇒ Object
286
287
288
|
# File 'lib/meilisearch/index.rb', line 286
def task(task_uid)
task_endpoint.index_task(task_uid)
end
|
#tasks ⇒ Object
290
291
292
|
# File 'lib/meilisearch/index.rb', line 290
def tasks
task_endpoint.index_tasks(@uid)
end
|
#typo_tolerance ⇒ Object
Also known as:
get_typo_tolerance
497
498
499
|
# File 'lib/meilisearch/index.rb', line 497
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
537
538
539
540
541
|
# File 'lib/meilisearch/index.rb', line 537
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=
432
433
434
435
|
# File 'lib/meilisearch/index.rb', line 432
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=
396
397
398
399
|
# File 'lib/meilisearch/index.rb', line 396
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=
519
520
521
522
523
|
# File 'lib/meilisearch/index.rb', line 519
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=
450
451
452
453
|
# File 'lib/meilisearch/index.rb', line 450
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
570
571
572
573
574
|
# File 'lib/meilisearch/index.rb', line 570
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
|
486
487
488
489
|
# File 'lib/meilisearch/index.rb', line 486
def ()
response = http_patch "/indexes/#{@uid}/settings/pagination",
Models::Task.new(response, task_endpoint)
end
|
#update_proximity_precision(proximity_precision_attribute) ⇒ Object
587
588
589
|
# File 'lib/meilisearch/index.rb', line 587
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=
341
342
343
344
|
# File 'lib/meilisearch/index.rb', line 341
def update_ranking_rules(ranking_rules)
response = http_put "/indexes/#{@uid}/settings/ranking-rules", ranking_rules
Models::Task.new(response, task_endpoint)
end
|
#update_searchable_attributes(searchable_attributes) ⇒ Object
Also known as:
searchable_attributes=
414
415
416
417
|
# File 'lib/meilisearch/index.rb', line 414
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
553
554
555
556
557
|
# File 'lib/meilisearch/index.rb', line 553
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=
323
324
325
326
|
# File 'lib/meilisearch/index.rb', line 323
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=,
468
469
470
471
|
# File 'lib/meilisearch/index.rb', line 468
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=
377
378
379
380
381
|
# File 'lib/meilisearch/index.rb', line 377
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=
359
360
361
362
|
# File 'lib/meilisearch/index.rb', line 359
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=
502
503
504
505
506
|
# File 'lib/meilisearch/index.rb', line 502
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
294
295
296
|
# File 'lib/meilisearch/index.rb', line 294
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
|