Skip to content

Changes related to the next Meilisearch release (v0.28.0) #329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0600ce1
Update README.md
meili-bot Jun 9, 2022
84eb912
Apply naming changes for search endpoint (#331)
curquiza Jun 15, 2022
fd1237e
Update .code-samples.meilisearch.yaml
meili-bot Jul 4, 2022
dbf7d09
Update HTTP methods (#330)
curquiza Jul 6, 2022
9e3dc91
Remove get_dump_status method from MeiliSearchClient
brunoocasali Jul 7, 2022
1b046fb
Merge pull request #335 from meilisearch/dump-changes
brunoocasali Jul 7, 2022
330f7cb
Replace uid by taskUid
brunoocasali Jul 7, 2022
5e32a15
Merge pull request #336 from meilisearch/tasks-v1
brunoocasali Jul 7, 2022
ab2d315
Fix tenant-token generation & Update key changes
brunoocasali Jul 7, 2022
c587204
Merge pull request #337 from meilisearch/keys-changes
brunoocasali Jul 7, 2022
66a1a33
Use ['results'] to map documents
brunoocasali Jul 7, 2022
1d7cad4
Fix missing tests
brunoocasali Jul 7, 2022
15db6e5
Fix rubocop issues
brunoocasali Jul 7, 2022
1e4cea5
Merge pull request #338 from meilisearch/documents-changes
brunoocasali Jul 7, 2022
be4e10b
Fix rubocop issues & re-run auto-gen-config
brunoocasali Jul 7, 2022
6a76079
Add limit and offset query params to client.keys method
brunoocasali Jul 7, 2022
e12ea73
Rename variable to be explicity about key and uid
brunoocasali Jul 7, 2022
e52325a
Add coverage to missing spots in the keys resource
brunoocasali Jul 7, 2022
e5e0915
Merge pull request #339 from meilisearch/fix-missing-tests
brunoocasali Jul 7, 2022
aa0cce9
Update code-samples with the latest v0.28 changes
brunoocasali Jul 7, 2022
cb38a23
Merge pull request #340 from meilisearch/keys-changes-v2
brunoocasali Jul 11, 2022
882921f
Add pagination and filtering to the tasks resources
brunoocasali Jul 7, 2022
1a9308d
Remove :next from ALLOWED_PARAMS
brunoocasali Jul 11, 2022
b4c1daf
Merge pull request #341 from meilisearch/tasks-changes-v2
brunoocasali Jul 11, 2022
20d1c31
Add support to paginate the indexes list
brunoocasali Jul 7, 2022
578c321
Add support to limit/offset/fields in the documents
brunoocasali Jul 7, 2022
9631b16
Add fields option to get_document
brunoocasali Jul 11, 2022
71881b1
Merge pull request #342 from meilisearch/indexes-and-docs
brunoocasali Jul 11, 2022
e831ed9
Update .code-samples.meilisearch.yaml
brunoocasali Jul 11, 2022
d2e426b
Fix rubocop offenses
brunoocasali Jul 11, 2022
57b09af
Merge pull request #334 from meilisearch/meili-bot/code-samples-v0-28
brunoocasali Jul 11, 2022
1ceeec7
Update .code-samples.meilisearch.yaml
brunoocasali Jul 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 38 additions & 31 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,26 @@
# the documentation on build
# You can read more on https://github.com/meilisearch/documentation/tree/master/.vuepress/code-samples
---
get_all_tasks_filtering_1: |-
client.index('movies').tasks
get_all_tasks_filtering_2: |-
client.tasks(status: ['succeeded', 'failed'], type: ['documentAdditionOrUpdate'])
get_all_tasks_paginating_1: |-
client.tasks(limit: 2, from: 10)
get_all_tasks_paginating_2: |-
client.tasks(limit: 2, from: 8)
get_pagination_settings_1: |-
update_pagination_settings_1: |-
reset_pagination_settings_1: |-
get_faceting_settings_1: |-
update_faceting_settings_1: |-
reset_faceting_settings_1: |-
settings_guide_faceting_1: |-
settings_guide_pagination_1: |-
get_one_index_1: |-
client.fetch_index('movies')
list_all_indexes_1: |-
client.indexes
client.indexes(limit: 3)
create_an_index_1: |-
client.create_index('movies', primary_key: 'id')
primary_field_guide_create_index_primary_key: |-
Expand All @@ -18,7 +34,7 @@ update_an_index_1: |-
delete_an_index_1: |-
client.delete_index('movies')
get_one_document_1: |-
client.index('movies').document(25684)
client.index('movies').document(25684, fields: ['id', 'title', 'poster', 'release_date'])
get_documents_1: |-
client.index('movies').documents(limit: 2)
primary_field_guide_add_document_primary_key: |-
Expand Down Expand Up @@ -57,10 +73,6 @@ delete_documents_1: |-
client.index('movies').delete_documents([23488, 153738, 437035, 363869])
search_post_1: |-
client.index('movies').search('american ninja')
get_task_by_index_1: |-
client.index('movies').task(1)
get_all_tasks_by_index_1: |-
client.index('movies').tasks
get_task_1: |-
client.task(1)
get_all_tasks_1: |-
Expand Down Expand Up @@ -103,6 +115,12 @@ update_settings_1: |-
synonyms: {
wolverine: ['xmen', 'logan'],
logan: ['wolverine']
},
pagination: {
max_total_hits: 5000
},
faceting: {
max_values_per_facet: 200
}
})
reset_settings_1: |-
Expand Down Expand Up @@ -243,9 +261,9 @@ search_parameter_guide_highlight_tag_1: |-
highlight_pre_tag: '<span class="highlight">',
highlight_post_tag: '</span>'
})
search_parameter_guide_matches_1: |-
search_parameter_guide_show_matches_position_1: |-
client.index('movies').search('winter feast', {
matches: true
show_matches_position: true
})
settings_guide_synonyms_1: |-
client.index('tops').update_settings({
Expand Down Expand Up @@ -345,18 +363,14 @@ faceted_search_filter_1: |-
client.index('movies').search('thriller', {
filter: [['genres = Horror', 'genres = Mystery'], 'director = "Jordan Peele"']
})
faceted_search_facets_distribution_1: |-
client.index('movies').search('Batman', {
facets_distribution: ['genres']
})
faceted_search_facets_1: |-
client.index('movies').search('Batman', { facets: ['genres'] })
faceted_search_walkthrough_filter_1: |-
client.index('movies').search('thriller', {
filter: [['genres = Horror', 'genres = Mystery'], 'director = "Jordan Peele"']
})
post_dump_1: |-
client.create_dump
get_dump_status_1: |-
client.get_dump_status('20201006-053243949')
phrase_search_1: |-
client.index('movies').search('"african american" horror')
sorting_guide_update_sortable_attributes_1: |-
Expand Down Expand Up @@ -401,9 +415,9 @@ authorization_header_1: |-
client = MeiliSearch::Client.new('http://127.0.0.1:7700', 'masterKey')
client.keys
get_one_key_1: |-
client.key('d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4')
client.key('6062abda-a5aa-4414-ac91-ecd7944c0f8d')
get_all_keys_1: |-
client.keys
client.keys(limit: 3)
create_a_key_1: |-
client.create_key(
description: 'Add documents: Products API key',
Expand All @@ -413,28 +427,20 @@ create_a_key_1: |-
)
update_a_key_1: |-
client.update_key(
'd0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4',
'6062abda-a5aa-4414-ac91-ecd7944c0f8d',
{
description: 'Manage documents: Products/Reviews API key',
actions: [
'documents.add',
'documents.delete'
],
indexes: [
'products',
'reviews'
],
expires_at: '2042-04-02T00:42:42Z'
name: 'Products/Reviews API key'
}
)
delete_a_key_1: |-
client.delete_key('d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4')
client.delete_key('6062abda-a5aa-4414-ac91-ecd7944c0f8d')
security_guide_search_key_1: |-
client = MeiliSearch::Client.new('http://127.0.0.1:7700', 'apiKey')
client.index('patient_medical_records').search
security_guide_update_key_1: |-
client = MeiliSearch::Client.new('http://127.0.0.1:7700', 'masterKey')
client.update_key('d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4', indexes: ['doctors'])
client.update_key('74c9c733-3368-4738-bbe5-1d18a5fecb37', description: 'Default Search API Key')
security_guide_create_key_1: |-
client = MeiliSearch::Client.new('http://127.0.0.1:7700', 'masterKey')
client.create_key(
Expand All @@ -448,8 +454,9 @@ security_guide_list_keys_1: |-
client.keys
security_guide_delete_key_1: |-
client = MeiliSearch::Client.new('http://127.0.0.1:7700', 'masterKey')
client.delete_key('d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4')
client.delete_key('ac5cd97d-5a4b-4226-a868-2d0eb6d197ab')
tenant_token_guide_generate_sdk_1: |-
uid = '85c3c2f9-bdd6-41f1-abd8-11fcf80e0f76'
api_key = 'B5KdX2MY2jV6EXfUs6scSfmC...'
expires_at = Time.new(2025, 12, 20).utc
search_rules = {
Expand All @@ -458,7 +465,7 @@ tenant_token_guide_generate_sdk_1: |-
}
}

token = client.generate_tenant_token(search_rules, api_key: api_key, expires_at: expires_at)
token = client.generate_tenant_token(uid, search_rules, api_key: api_key, expires_at: expires_at)
tenant_token_guide_search_sdk_1: |-
front_end_client = MeiliSearch::Client.new('http://127.0.0.1:7700', token)

Expand All @@ -481,7 +488,7 @@ getting_started_update_searchable_attributes: |-
getting_started_update_stop_words: |-
client.index('movies').update_stop_words(['the'])
getting_started_check_task_status: |-
client.index('movies').task(0)
client.task(0)
getting_started_synonyms: |-
client.index('movies').update_synonyms({
winnie: ['piglet'],
Expand Down
12 changes: 3 additions & 9 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-04-26 02:54:29 UTC using RuboCop version 1.26.1.
# on 2022-07-11 13:40:51 UTC using RuboCop version 1.29.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -14,22 +14,16 @@ Gemspec/RequireMFA:
Exclude:
- 'meilisearch.gemspec'

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
Layout/HeredocIndentation:
Exclude:
- 'spec/meilisearch/index/documents_spec.rb'

# Offense count: 43
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 558
Max: 524

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 277
Max: 280

# Offense count: 1
# Configuration parameters: Max, CountKeywordArgs.
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ JSON output:
]
}
],
"nbHits": 1,
"exhaustiveNbHits": false,
"estimatedTotalHits": 1,
"query": "wonder",
"limit": 20,
"offset": 0,
Expand All @@ -198,7 +197,7 @@ JSON output:

## 🤖 Compatibility with Meilisearch

This package only guarantees the compatibility with the [version v0.27.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.27.0).
This package only guarantees the compatibility with the [version v0.28.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.28.0).

## 💡 Learn More

Expand Down
44 changes: 24 additions & 20 deletions lib/meilisearch/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ class Client < HTTPRequest

### INDEXES

def raw_indexes
http_get('/indexes')
def raw_indexes(options = {})
body = Utils.transform_attributes(options.transform_keys(&:to_sym).slice(:limit, :offset))

http_get('/indexes', body)
end

def indexes
raw_indexes.map do |index_hash|
def indexes(options = {})
response = raw_indexes(options)

response['results'].map! do |index_hash|
index_object(index_hash['uid'], index_hash['primaryKey'])
end

response
end

# Usage:
Expand All @@ -29,7 +35,7 @@ def create_index(index_uid, options = {})
# Waits for the task to be achieved, be careful when using it.
def create_index!(index_uid, options = {})
task = create_index(index_uid, options)
wait_for_task(task['uid'])
wait_for_task(task['taskUid'])
end

def delete_index(index_uid)
Expand All @@ -52,12 +58,14 @@ def fetch_raw_index(index_uid)

### KEYS

def keys
http_get '/keys'
def keys(limit: nil, offset: nil)
body = { limit: limit, offset: offset }.compact

http_get '/keys', body
end

def key(key_uid)
http_get "/keys/#{key_uid}"
def key(uid_or_key)
http_get "/keys/#{uid_or_key}"
end

def create_key(key_options)
Expand All @@ -66,14 +74,15 @@ def create_key(key_options)
http_post '/keys', body
end

def update_key(key_uid, key_options)
def update_key(uid_or_key, key_options)
body = Utils.transform_attributes(key_options)
body = body.slice('description', 'name')

http_patch "/keys/#{key_uid}", body
http_patch "/keys/#{uid_or_key}", body
end

def delete_key(key_uid)
http_delete "/keys/#{key_uid}"
def delete_key(uid_or_key)
http_delete "/keys/#{uid_or_key}"
end

### HEALTH
Expand Down Expand Up @@ -105,15 +114,10 @@ def create_dump
http_post '/dumps'
end

def dump_status(dump_uid)
http_get "/dumps/#{dump_uid}/status"
end
alias get_dump_status dump_status

### TASKS

def tasks
task_endpoint.task_list
def tasks(options = {})
task_endpoint.task_list(options)
end

def task(task_uid)
Expand Down
Loading