Skip to content

Add get documents by ids #632

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Nymuxyzo
Copy link
Contributor

@Nymuxyzo Nymuxyzo commented May 31, 2025

Pull Request

Related issue

Fixes #628

What does this PR do?

  • Add the ability to fetch documents by Ids

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

  • New Features
    • Added support for retrieving documents by specifying an array of IDs when fetching documents.
  • Documentation
    • Updated method documentation to describe the new option for retrieving documents by IDs.
  • Tests
    • Introduced new test cases to verify document retrieval by IDs and combined usage with filters and limits.
  • Chores
    • Enhanced gem metadata with links to the source code repository and bug tracker.

Copy link

coderabbitai bot commented May 31, 2025

Walkthrough

The Meilisearch::Index#documents method was updated to support retrieving documents by an array of IDs via a new :ids option. The implementation and documentation were modified accordingly, and new tests were added to verify the correct behavior. The gemspec metadata was also updated.

Changes

File(s) Change Summary
lib/meilisearch/index.rb Added support for :ids option in documents method; updated documentation for the method.
spec/meilisearch/index/documents_spec.rb Added tests for retrieving documents by IDs, with/without limit and filter options.
meilisearch.gemspec Added source_code_uri and bug_tracker_uri to gemspec metadata.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Index as Meilisearch::Index
    participant MeiliServer as Meilisearch Server

    User->>Index: documents(ids: [...], filter: ..., limit: ...)
    alt With filter
        Index->>MeiliServer: POST /documents/fetch (filter, ids, limit)
    else Without filter
        Index->>MeiliServer: GET /documents?ids=...&limit=...
    end
    MeiliServer-->>Index: Return matching documents
    Index-->>User: Return documents
Loading

Assessment against linked issues

Objective Addressed Explanation
Update method to allow retrieving documents by IDs (#628)

Poem

A hop, a skip, a search for IDs,
Now rabbits fetch documents with ease!
With filters or limits, the docs obey,
Thanks to the changes merged today.
Bugs and code now clearly tracked,
The Meili warren stays on track! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b1cd31 and fefe5ed.

📒 Files selected for processing (3)
  • lib/meilisearch/index.rb (1 hunks)
  • meilisearch.gemspec (1 hunks)
  • spec/meilisearch/index/documents_spec.rb (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
spec/meilisearch/index/documents_spec.rb (1)
lib/meilisearch/index.rb (1)
  • documents (79-87)
lib/meilisearch/index.rb (2)
lib/meilisearch/utils.rb (3)
  • version_error_handler (58-66)
  • filter (44-46)
  • parse_query (48-56)
lib/meilisearch/http_request.rb (2)
  • http_post (39-51)
  • http_get (26-37)
🔇 Additional comments (6)
meilisearch.gemspec (1)

21-22: LGTM: Useful gem metadata additions.

The addition of source_code_uri and bug_tracker_uri metadata follows Ruby gem best practices and provides valuable information to gem users.

lib/meilisearch/index.rb (2)

76-76: Good documentation update.

The documentation clearly describes the new :ids parameter and its purpose.


82-84: Consistent implementation following existing patterns.

The :ids parameter is correctly added to both request paths:

  • POST requests (with filter) use Utils.filter which will include :ids in the request body
  • GET requests (without filter) use Utils.parse_query which will convert the :ids array to a comma-separated string in query parameters

This follows the same pattern as other parameters like :limit, :offset, :fields, and :filter.

spec/meilisearch/index/documents_spec.rb (3)

426-432: Comprehensive test for basic ids functionality.

This test properly verifies that documents can be retrieved by specifying their IDs and confirms both the returned documents and the total count.


434-439: Good test for parameter interaction.

This test ensures that the limit parameter continues to work correctly when combined with the :ids parameter, which is important for maintaining backward compatibility.


441-444: Excellent test for filter interaction.

This test verifies that the :ids parameter works correctly with the :filter parameter, ensuring that the filtering logic is applied properly when both are present.

✨ 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented May 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (5b1cd31) to head (fefe5ed).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #632   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          804       804           
=========================================
  Hits           804       804           

☔ 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.

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.14] Get documents by ID
1 participant