Skip to content

Conversation

@aznszn
Copy link

@aznszn aznszn commented Jan 13, 2026

Pull Request

Related issue

Closes #1142

What does this PR do?

  • changed swap_indexes definition to accept the rename key
  • changed comment on update function to indicate that it can rename indexes too
  • added code example equivalent to the rename index CURL example under the rename_an_index_1 key in .code-samples.meilisearch.yml

Besides this, the changes mentioned in #1142 were already done, including tests

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?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

Release Notes

  • Documentation

    • Added code example demonstrating how to rename an index.
  • Improvements

    • Enhanced index swapping functionality with support for additional parameter types.
    • Clarified that index updates support modifications to both primary keys and identifiers.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

The changes add support for index renaming in the Meilisearch Python SDK. The swap_indexes method signature is updated to accept boolean values in mapping parameters (enabling a rename flag), the index update method's docstring is clarified to document UID renaming capability, and a code example demonstrates renaming an index via the update method with new_uid.

Changes

Cohort / File(s) Change Summary
API Signature Updates
meilisearch/client.py
Updated swap_indexes method parameter type from List[Mapping[str, List[str]]] to List[Mapping[str, List[str] | bool]] to support boolean rename flags in swap operations
Documentation Updates
meilisearch/index.py
Updated update method docstring to include "or uid" in description, reflecting capability to rename index via new_uid parameter
Code Samples
.code-samples.meilisearch.yaml
Added rename_an_index_1 example demonstrating index renaming using index.update(new_uid="NEW_NAME")

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • Rename index #1170: Updates swap_indexes to support and document the rename flag functionality in index swapping operations

Suggested labels

enhancement

Suggested reviewers

  • jawad-khan
  • Strift

Poem

🐰 Swap and rename with grace so true,
From INDEX_A to INDEX_B—brand new!
With booleans that flip and UIDs that shift,
Your indexes dance in Meilisearch's gift!

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially addresses issue #1142: swap_indexes now accepts rename flag, update docstring clarified renaming capability, and rename_an_index_1 code sample added. However, queryVector search response support is absent. Implement queryVector field in search responses when retrieveVectors is used, as required by issue #1142.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'index renaming support' clearly and concisely summarizes the main objective of adding index renaming functionality, which aligns with the primary changes across all modified files.
Out of Scope Changes check ✅ Passed All changes directly relate to index renaming support (swap_indexes signature, update docstring, code sample). No out-of-scope modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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
Contributor

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
meilisearch/index.py (1)

108-152: Docstring should document the primaryKey constraint.

The implementation correctly:

  • Validates that at least one of primary_key or new_uid is provided
  • Supports updating both fields in a single PATCH request
  • Documents the stale instance behavior after renaming

However, the docstring omits a critical constraint: primaryKey can only be changed when the index is empty. Users calling update(primary_key="new_key") on an index with documents will receive an API error. Add documentation warning that the index must be empty before changing the primary key, similar to the existing warning about stale instances after rename.

🧹 Nitpick comments (1)
meilisearch/client.py (1)

652-674: Type signature correctly updated for rename support.

The type change from List[Mapping[str, List[str]]] to List[Mapping[str, List[str] | bool]] correctly models the new payload structure where each mapping can contain:

  • "indexes": a list of strings
  • "rename": a boolean (optional)

Minor nit: The docstring parameter description at line 657 says indexes: but the actual parameter is named parameters. Consider updating for consistency.

📝 Suggested docstring fix
         """Swap two indexes.

         Parameters
         ----------
-        indexes:
+        parameters:
             List of indexes to swap ex:
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2c20831 and 205a388.

📒 Files selected for processing (3)
  • .code-samples.meilisearch.yaml
  • meilisearch/client.py
  • meilisearch/index.py
🔇 Additional comments (1)
.code-samples.meilisearch.yaml (1)

817-818: LGTM!

The code sample correctly demonstrates the index rename functionality using the update method with new_uid, matching the PR objective to add the rename_an_index_1 example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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

1 participant