Add Meilisearch v1.18.0 support#663
Conversation
WalkthroughAdds support for Meilisearch 1.18.0 features: index renaming via Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (5)
lib/meilisearch/client.rb (1)
44-48: swap_indexes hash support and mapping logic look good; consider clarifying the YARD param type.Preserving hash entries and only wrapping non-hash arguments in
{ indexes: entry }cleanly extendsswap_indexesto support rename semantics without breaking existing array-based calls. The@param optionsannotation still describes anArray<Array(String, String)>, Array<Hash>, while the public API is actually varargs (*options) and also accepts lone hashes (e.g.,swap_indexes(indexes: [...])). You might want to relax or rephrase the type/description to reflect “one or more entries, each either an Array of two uids or a Hash with at least :indexes (and optional :rename)”, to better match real usage.Also applies to: 51-56
spec/meilisearch/index/search/vector_search_spec.rb (1)
4-22: Vector search specs cover both basic and retrieve_vectors flows well.Using shared
documentsandsettingssetup keeps the examples focused, and the new example assertingqueryVectorplus_vectors.custom.embeddingsas floats gives solid coverage for the new response shape whenretrieve_vectors: trueis used. If you want to shave a bit of duplication, you could extract the repeated “create index / update_settings / add_documents” sequence into a small helper orbeforeblock, but that’s purely optional.Also applies to: 23-39, 41-58
lib/meilisearch/index.rb (1)
49-64: Index#update docs correctly describe rename behaviour; minor type annotation could be loosened.The added examples and notes about preserving documents/settings, failure conditions, and pointing to
Client#swap_indexesfor atomic swaps make the rename behaviour much clearer. The@param bodytype ofHash{String => String}is tighter than what callers actually pass (symbol keys and non-string values such as arrays), though; consider relaxing it to justHashorHash{Symbol => Object}so the YARD signature matches real usage.Also applies to: 66-73
spec/meilisearch/client/indexes_spec.rb (1)
277-324: New swap_indexes tests exercise hash input and rename semantics comprehensively.The added examples cover hash-only usage, renaming via
rename: true, multiple swaps in a single call, and the failure case when renaming a non-existent index, all while validating both task type and details. To make the specs a bit more future-proof, you might consider:
- In the “swaps and renames indexes in a single call” example, only asserting the
indexesfor the non-renaming swap and keeping the'rename' => truecheck for the renaming one, so the test doesn’t depend on the API always emitting an explicitrename: falsefield.- Ensuring (if not already handled in shared test setup) that the uids used here are isolated per example or cleaned up, so the “non-existent index” case can’t accidentally be affected by other tests creating the same uids.
Both are minor polish; the current tests are otherwise solid.
spec/meilisearch/index/rename_spec.rb (1)
1-105: Rename specs are thorough and match the documented behaviours.This suite covers the key paths: successful rename (including timestamps), conflicts with an existing target uid, missing source index, invalid uid format, preservation of documents, primary key changes, stats, and selected settings. All async operations are awaited before assertions, which keeps the expectations reliable. If you want the setup to be a bit more self-documenting, you could optionally add an explicit
create_indexin the examples that currently rely on implicit index creation viaadd_documents/update_settings, but functionally the tests look good as-is.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.code-samples.meilisearch.yaml(2 hunks)lib/meilisearch/client.rb(1 hunks)lib/meilisearch/index.rb(1 hunks)spec/meilisearch/client/indexes_spec.rb(1 hunks)spec/meilisearch/index/rename_spec.rb(1 hunks)spec/meilisearch/index/search/vector_search_spec.rb(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
spec/meilisearch/index/search/vector_search_spec.rb (1)
lib/meilisearch/index.rb (5)
update_settings(727-730)settings(714-716)add_documents(158-163)documents(128-136)search(589-598)
spec/meilisearch/index/rename_spec.rb (4)
lib/meilisearch/client.rb (3)
create_index(95-101)index(137-139)fetch_index(146-148)lib/meilisearch/models/task.rb (4)
await(114-121)type(41-43)uid(37-39)error(98-100)lib/meilisearch/index.rb (7)
task(656-658)update(70-73)add_documents(158-163)documents(128-136)stats(680-682)update_settings(727-730)settings(714-716)spec/support/exceptions_helpers.rb (2)
raise_index_not_found_meilisearch_api_error(21-27)raise_meilisearch_api_error_with(4-11)
🔇 Additional comments (1)
.code-samples.meilisearch.yaml (1)
105-106: New rename and retrieve_vectors samples look consistent and idiomatic.The rename example uses
update(uid: 'indexB')with the same pattern as the existing primary key example, and theretrieve_vectors: truesample uses the expected Ruby option names (retrieve_vectors,hybrid,embedder) and matches the surrounding code-sample style. No changes needed.Also applies to: 676-682
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #663 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 806 806
=========================================
Hits 806 806 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Pull Request
Related issue
Fixes #650
What does this PR do?
PR checklist
Please check if your PR fulfills the following requirements:
Summary by CodeRabbit
Release Notes
New Features
retrieve_vectorsparameterDocumentation
✏️ Tip: You can customize this high-level summary in your review settings.