-
Notifications
You must be signed in to change notification settings - Fork 102
Add method to get documents by ID #724
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis PR implements document retrieval by IDs in the Meilisearch Rust SDK. A new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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.
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 (2)
src/documents.rs (2)
327-348: Consider documenting interaction withfilterparameter.The
with_ids()method implementation is correct and follows the established builder pattern. However, the documentation could clarify what happens when bothwith_ids()andwith_filter()are used together on the same query.Consider adding a note to the documentation:
/// Specify a list of document IDs to retrieve. /// /// Note: When combined with `with_filter()`, both conditions may apply. /// Refer to Meilisearch API documentation for the exact behavior. /// /// # Example
504-515: Consider verifying the actual document IDs in the test.The test correctly validates that 2 documents are returned, but could be strengthened by verifying that the returned documents have the expected IDs.
Apply this diff to make the test more thorough:
#[meilisearch_test] async fn test_get_documents_by_ids(client: Client, index: Index) -> Result<(), Error> { setup_test_index(&client, &index).await?; let documents = DocumentsQuery::new(&index) .with_ids(["1", "3"]) // retrieve by IDs .execute::<MyObject>() .await?; assert_eq!(documents.results.len(), 2); + // Verify that the correct documents were retrieved + let ids: Vec<_> = documents.results.iter().filter_map(|d| d.id).collect(); + assert!(ids.contains(&1)); + assert!(ids.contains(&3)); Ok(()) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.code-samples.meilisearch.yaml(1 hunks)src/documents.rs(4 hunks)src/indexes.rs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/documents.rs (2)
src/indexes.rs (23)
client(186-188)client(232-234)client(320-322)client(376-378)client(428-430)client(473-475)client(522-525)client(556-558)client(634-636)client(700-702)client(970-972)client(1038-1040)client(1089-1091)client(1133-1135)client(1186-1188)client(1245-1247)index(2171-2171)index(2188-2189)index(2226-2226)index(2298-2298)index(2326-2326)index(2352-2352)index(2379-2379)src/search.rs (3)
index(728-728)index(2055-2058)setup_test_index(1165-1188)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: integration-tests
🔇 Additional comments (4)
.code-samples.meilisearch.yaml (1)
145-151: LGTM! Clear example of the new feature.The code sample effectively demonstrates the new
with_ids()functionality. The usage is consistent with the existing API patterns in this file.src/indexes.rs (1)
520-520: Verify behavior when bothfilterandidsare provided.The routing logic correctly uses the fetch endpoint when either
filteroridsis present. However, ensure that the Meilisearch API supports combining bothfilterandidsin the same request. If not, consider adding validation or documentation about this scenario.Can you confirm whether the Meilisearch v1.14 API supports using both
filterandidsparameters simultaneously in the/documents/fetchendpoint? If only one is supported at a time, the SDK should either validate this or document the behavior clearly.src/documents.rs (2)
206-213: LGTM! Well-documented field addition.The
idsfield is correctly typed and documented. The note about string representation of IDs is particularly helpful for users with numeric IDs.
216-228: LGTM! Constructor correctly initializes the new field.The
idsfield is properly initialized toNone, consistent with other optional fields in the struct.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #724 +/- ##
==========================================
+ Coverage 86.18% 86.22% +0.03%
==========================================
Files 20 20
Lines 6263 6280 +17
==========================================
+ Hits 5398 5415 +17
Misses 865 865 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@curquiza Could you review some of the opened PRs? |
Pull Request
Related issue
Fixes #662
What does this PR do?
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!
Summary by CodeRabbit
New Features
Documentation