Skip to content

Add Meilisearch v1.18.0 support#663

Merged
curquiza merged 3 commits intomeilisearch:mainfrom
psylone:feat/support-v1.18
Dec 29, 2025
Merged

Add Meilisearch v1.18.0 support#663
curquiza merged 3 commits intomeilisearch:mainfrom
psylone:feat/support-v1.18

Conversation

@psylone
Copy link
Copy Markdown
Contributor

@psylone psylone commented Dec 9, 2025

Pull Request

Related issue

Fixes #650

What does this PR do?

  • Add index rename docs and specs
  • Support index renaming via swap_indexes
  • Add spec for retrieve_vectors search parameter

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for retrieving vectors in search results using the retrieve_vectors parameter
    • Enhanced index swap functionality for more flexible index operations
  • Documentation

    • Clarified that index updates can now rename the index UID and/or update the primary key
    • Added code examples demonstrating index renaming and vector retrieval in search operations

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 9, 2025

Walkthrough

Adds support for Meilisearch 1.18.0 features: index renaming via Index#update() and enhanced swap_indexes() method, queryVector in search responses with retrieve_vectors, test coverage, and code samples.

Changes

Cohort / File(s) Summary
Code Samples Configuration
.code-samples.meilisearch.yaml
Added two new code-sample entries: rename_an_index_1 (demonstrating index renaming via update(uid:)) and search_parameter_reference_retrieve_vectors_1 (demonstrating retrieve_vectors with hybrid embedder).
Client Library Updates
lib/meilisearch/client.rb
Enhanced swap_indexes method to accept either array pairs or explicit hashes for flexible index renaming; non-hash entries wrapped as { indexes: entry } while provided hashes preserved as-is; updated parameter annotation to include Array<Hash>; documentation expanded to clarify rename behavior.
Index API Documentation
lib/meilisearch/index.rb
Updated Index#update method documentation to reflect index renaming capability via :uid option and primary key updates; added examples for rename-only, primary-key-only, and combined operations; expanded behavior notes on document/setting preservation and atomic swap via swap_indexes.
Client Integration Tests
spec/meilisearch/client/indexes_spec.rb
Added comprehensive specs for swap_indexes: hash input validation, index renaming with UID verification, multi-group swaps with/without renaming, error handling for non-existent indexes, and task completion verification.
Index Rename Tests
spec/meilisearch/index/rename_spec.rb
New test suite covering successful rename with UID/timestamp validation, failure scenarios (target UID exists, source non-existent, invalid format), document/setting/primary-key preservation across renames, and index stats consistency.
Vector Search Tests
spec/meilisearch/index/search/vector_search_spec.rb
Refactored test setup into let! blocks for documents and settings; added new test verifying retrieve_vectors: true returns queryVector and _vectors in hits with embeddings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • lib/meilisearch/client.rb: Review the flexibility added to swap_indexes parameter handling—verify hash preservation logic and edge cases with mixed input types.
  • spec/meilisearch/index/rename_spec.rb: Largest new test file; review error scenarios and post-rename state assertions for thoroughness.
  • spec/meilisearch/client/indexes_spec.rb: Large test additions; ensure task awaiting and assertion patterns are consistent and robust.

Possibly related PRs

Suggested labels

maintenance

Suggested reviewers

  • curquiza

Poem

🐰 Indexes hop and swap with grace,
Renaming now finds its place,
Vectors bloom with queries bright,
Eighteen shines—our SDK takes flight! ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add Meilisearch v1.18.0 support' is clear and directly reflects the main objective: adding support for Meilisearch v1.18.0 features including queryVector and index renaming.
Linked Issues check ✅ Passed The PR implements all coding objectives from issue #650: queryVector support in search responses, index renaming via swap_indexes method, index renaming via update method, comprehensive test coverage, and code samples.
Out of Scope Changes check ✅ Passed All changes are directly scoped to supporting Meilisearch v1.18.0: code samples, client swap_indexes enhancements, index update documentation, and test coverage for queryVector and index renaming.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 extends swap_indexes to support rename semantics without breaking existing array-based calls. The @param options annotation still describes an Array<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 documents and settings setup keeps the examples focused, and the new example asserting queryVector plus _vectors.custom.embeddings as floats gives solid coverage for the new response shape when retrieve_vectors: true is 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 or before block, 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_indexes for atomic swaps make the rename behaviour much clearer. The @param body type of Hash{String => String} is tighter than what callers actually pass (symbol keys and non-string values such as arrays), though; consider relaxing it to just Hash or Hash{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 indexes for the non-renaming swap and keeping the 'rename' => true check for the renaming one, so the test doesn’t depend on the API always emitting an explicit rename: false field.
  • 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_index in the examples that currently rely on implicit index creation via add_documents/update_settings, but functionally the tests look good as-is.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20de69c and 73de8ea.

📒 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 the retrieve_vectors: true sample 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

Copy link
Copy Markdown
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@curquiza curquiza enabled auto-merge December 29, 2025 17:41
@curquiza curquiza added the enhancement New feature or request label Dec 29, 2025
@curquiza curquiza added this pull request to the merge queue Dec 29, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (20de69c) to head (73de8ea).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Merged via the queue into meilisearch:main with commit 4e7ab12 Dec 29, 2025
8 checks passed
@psylone psylone deleted the feat/support-v1.18 branch December 29, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v1.18.0] Add queryVector to search responses and support index renaming

2 participants