-
Notifications
You must be signed in to change notification settings - Fork 103
Add support for sorting on the documents API #711
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
WalkthroughAdded optional sorting support to DocumentsQuery by introducing a public sort field, initializing it in the constructor, and providing a with_sort builder method. Tests were added within the same module to validate sorted retrieval when sortable attributes are configured. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Client App
participant SDK as SDK DocumentsQuery
participant HTTP as HTTP Client
participant MS as Meilisearch Server
Dev->>SDK: DocumentsQuery::new(index)
Dev->>SDK: with_sort(["price:asc","rating:desc"])
Dev->>SDK: execute()
SDK->>HTTP: GET /indexes/{uid}/documents?sort=price:asc,rating:desc
HTTP->>MS: Request with sort param
MS-->>HTTP: 200 OK (documents in requested order)
HTTP-->>SDK: Response
SDK-->>Dev: Documents (sorted)
note over MS,SDK: If sortable attributes not configured, server may error per API rules
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal). Please share your feedback with us on this Discord post. 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 (3)
src/documents.rs (3)
193-198
: Addsort
field: LGTM. Consider API consistency withSearchQuery
.Works as intended. Optional: align the type with
SearchQuery
(Option<&'a [&'a str]>) for cross-API consistency. Both serialize fine; this is mostly about uniformity. Based on relevant code snippets
287-311
:with_sort
builder: LGTM. Optional parity withSearchQuery
.Current iterator-based API is ergonomic. If desired, add a slice-based overload (accepts &'a [&'a str]) to mirror
SearchQuery::with_sort
for parity. Based on relevant code snippets
573-599
: Sorting test: LGTM. Optional extra assertions.Test validates descending order. Consider adding:
- An ascending case (id:asc) to cover both orders.
- A negative case (sorting on a non-sortable attribute) to assert the expected Meilisearch error.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/documents.rs
(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/documents.rs (2)
src/search.rs (8)
with_sort
(571-574)index
(724-724)index
(2050-2053)setup_test_index
(1160-1183)new
(39-41)new
(425-457)new
(744-749)new
(996-1007)src/indexes.rs (26)
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)new
(81-89)new
(1783-1790)new
(1994-2000)
⏰ 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 (1)
src/documents.rs (1)
215-215
: Constructor initializessort
toNone
: LGTM.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #711 +/- ##
==========================================
+ Coverage 85.89% 85.95% +0.05%
==========================================
Files 19 19
Lines 5950 5975 +25
==========================================
+ Hits 5111 5136 +25
Misses 839 839 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Pull Request
Related issue
Fixes #699
What does this PR do?
As per the requirements of the Meilisearch 1.16 the goal was to update the SDK to allow the sorting on the documents API.
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!
Summary by CodeRabbit