Add custom metadata support for document tasks#736
Conversation
📝 WalkthroughWalkthroughAdds an optional per-request Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant Index
participant DocQuery as DocumentTaskQuery
participant HTTP
participant TaskInfo
rect rgba(120,180,240,0.08)
App->>Index: add_documents(docs, primary_key, custom_metadata)
note right of Index: builds DocumentTaskQuery(primary_key, custom_metadata)
Index->>DocQuery: DocumentTaskQuery::new(primary_key, custom_metadata)
Index->>HTTP: POST /indexes/{uid}/documents\n(payload: DocQuery + docs)
end
rect rgba(160,220,140,0.08)
HTTP->>TaskInfo: returns TaskInfo JSON (includes customMetadata)
TaskInfo->>App: TaskInfo { custom_metadata: Some("..."), ... }
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/tasks.rs (1)
154-175: Exposecustom_metadataon task variants in a backward-compatible wayAdding
pub custom_metadata: Option<String>toSucceededTask,EnqueuedTask, andProcessingTaskunder#[serde(rename_all = "camelCase")]correctly maps the server’scustomMetadatafield and remains backward-compatible for deserialization (field is optional and existing JSON still matches via..patterns in tests). Consider adding a brief doc comment on this field to make its relation to Meilisearch’s “tasks custom metadata” feature explicit for SDK users.Also applies to: 183-196, 204-219
src/documents.rs (1)
415-427: DocumentDeletionQuery metadata extension looks correct and keeps API stable
executedelegating toexecute_with_custom_metadatawithNonepreserves the old API while adding the new capability. Lifetimes oncustom_metadata: Option<&'a str>are consistent with the struct’s lifetime, and the call intoIndex::delete_documents_withmatches the new signature.One minor nit: the generic
T: DeserializeOwned + 'staticon both methods is now unused; if you ever do a breaking release, consider simplifying these to non‑generic fns or adding aPhantomData<T>to avoid the unused type parameter warning. For now, this is harmless and keeps source compatibility.src/indexes.rs (1)
592-666: Write/update document routes correctly propagatecustom_metadataFor
add_or_replace,add_documents,add_or_update, and their*_unchecked_payload/ NDJSON / CSV variants, the extracustom_metadata: Option<&str>is consistently threaded into aDocumentTaskQuery::new(primary_key, custom_metadata)used as the request’s query payload. This keeps existing primary key behavior intact while adding metadata support on all the expected code paths, including streaming ones.Given the repeated pattern (build URL, construct
DocumentTaskQuery, then callrequestorstream_request), you might later consider a small private helper to reduce duplication, but it’s not necessary for clarity or correctness right now.Also applies to: 706-739, 779-846, 884-940, 942-1013, 1055-1078
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
examples/cli-app-with-awc/src/main.rs(1 hunks)examples/cli-app/src/main.rs(1 hunks)examples/web_app_graphql/src/graphql_schema/users/query/search.rs(2 hunks)src/client.rs(6 hunks)src/documents.rs(5 hunks)src/indexes.rs(51 hunks)src/lib.rs(2 hunks)src/search.rs(3 hunks)src/task_info.rs(5 hunks)src/tasks.rs(5 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-12T13:28:23.700Z
Learnt from: LukasKalbertodt
Repo: meilisearch/meilisearch-rust PR: 625
File: src/search.rs:368-370
Timestamp: 2025-06-12T13:28:23.700Z
Learning: In the Meilisearch Rust client, `SearchQuery` serializes its per-query federation settings under the key `federationOptions`; only the top-level multi-search parameter is named `federation`.
Applied to files:
src/client.rs
🧬 Code graph analysis (7)
src/tasks.rs (1)
src/client.rs (2)
None(1532-1532)None(1613-1613)
src/task_info.rs (1)
src/client.rs (2)
None(1532-1532)None(1613-1613)
examples/cli-app-with-awc/src/main.rs (1)
src/client.rs (2)
None(1532-1532)None(1613-1613)
src/search.rs (1)
src/client.rs (2)
None(1532-1532)None(1613-1613)
examples/cli-app/src/main.rs (1)
src/client.rs (2)
None(1532-1532)None(1613-1613)
src/client.rs (2)
src/reqwest.rs (1)
qualified_version(131-135)src/batches.rs (3)
None(141-141)None(169-169)None(193-193)
src/indexes.rs (2)
src/documents.rs (7)
new(89-94)new(218-228)new(400-405)index(62-64)index(161-161)index(383-383)index(544-544)src/request.rs (1)
query(39-47)
⏰ 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 (16)
examples/cli-app-with-awc/src/main.rs (1)
186-194: Example call correctly updated for newadd_or_updatesignatureAdding the trailing
Nonekeeps this example in sync with the newadd_or_updateAPI while preserving existing behavior (no custom metadata sent).src/lib.rs (2)
29-38: Top-level “Add Documents” doctest matches extendedadd_documentsAPIThe extra
Noneparameter correctly accounts for the new optional metadata argument without changing the example’s behavior.
182-190: Filterable attributes doctest updated consistently for metadata argumentThis doctest’s
add_documentscall now matches the three-argument signature and keeps the example behavior intact by passingNonemetadata.examples/web_app_graphql/src/graphql_schema/users/query/search.rs (1)
24-38: GraphQL example updated correctly foradd_documentsmetadata parameterBoth
add_documentscalls now include the new optional metadata argument asNone, keeping control flow and behavior identical while aligning with the updated API.examples/cli-app/src/main.rs (1)
110-118: CLI example synchronized with newadd_or_updatesignatureThe additional
Noneargument for metadata is correct and keeps this example compiling and behaving as before.src/tasks.rs (1)
290-299: Docs and tests now use three-argumentadd_documentsconsistentlyThe Task docs example and all affected tests now call
add_documentswith(…, primary_key_opt, None)which matches the extended API and keeps the existing semantics (no metadata) while exercising the new parameter.Also applies to: 935-961, 1225-1238, 1258-1289
src/task_info.rs (1)
9-18:TaskInfonow surfacescustom_metadatawith solid deserialization coverageExposing
pub custom_metadata: Option<String>onTaskInfo(camelCase serde) matches the server field, and the updatedtest_deserialize_task_infoverifies correct mapping from"customMetadata". The updatedadd_documents(&[..], None, None)usage in the async test keeps behavior unchanged while aligning with the new API.Also applies to: 114-141, 145-176
src/search.rs (1)
972-985: Search examples/tests correctly updated for metadata-aware document APIsThe facet-search documentation now calls
add_or_replacewith the extra metadata argument asNone, and bothsetup_test_indexhelpers use the three-argumentadd_documentssignature. All of these keep test and example behavior intact while matching the new API.Also applies to: 1225-1238, 1258-1289
src/client.rs (2)
167-191: Client documentation kept in sync with extended document/task APIsThe multi-search,
wait_for_task, andget_taskexamples now useadd_or_replace,add_documents, anddelete_all_documentswith their updated signatures (extra metadata or options argument), consistently passingNonewhere no metadata is desired. This maintains example behavior while matching the new public API surface.Also applies to: 889-919, 956-968
1548-1549: Tests correctly importqualified_versionand use newadd_documentssignatureBringing
reqwest::qualified_versioninto scope matches its use intest_methods_has_qualified_version_as_header, and the twoadd_documentscalls intest_swapping_two_indexesnow include the trailingNonemetadata argument, keeping the test logic unchanged but compatible with the updated API.Also applies to: 1560-1580
src/documents.rs (1)
144-144: Updated call sites for extracustom_metadataparameter are consistentThe additional
Nonearguments wired intoadd_or_replacein the doctest,setup_test_index, and the twodelete_documents_withtest calls align with the new API and keep existing behavior (no metadata) unchanged.Also applies to: 488-488, 540-541, 569-570
src/indexes.rs (5)
80-103:DocumentTaskQuerydesign matches Meilisearch query conventionsThe internal
DocumentTaskQuery<'a>cleanly encapsulatesprimary_keyandcustom_metadatawith#[serde(rename_all = "camelCase")]andskip_serializing_if = "Option::is_none", which should serialize to the expectedprimaryKey/customMetadataquery parameters only when present. Using separate constructors (newandwith_metadata) keeps call sites clear between routes that also set a primary key and those that only tag tasks.No issues from a correctness perspective.
1080-1131: Delete document APIs now support per-task metadata without changing semantics
delete_all_documents,delete_document,delete_documents, anddelete_documents_withnow all acceptcustom_metadata: Option<&str>and wrap it viaDocumentTaskQuery::with_metadata(custom_metadata)passed as the query component of the HTTP method. Bodies (when present) remain unchanged, so server-side behavior for filters and ID lists is preserved; only the optional metadata is new.The use of
Method::<_, ()>::Delete { query }for DELETE routes is type-correct with the genericMethod<Q, B>definition, and lifetimes on the borrowed&strmetadata are no stricter than existing borrowed query structs elsewhere in this module.Also applies to: 1133-1185, 1187-1242, 1285-1302
1673-1687: Batch helpers correctly fan outcustom_metadataper produced task
add_documents_in_batchesandupdate_documents_in_batchesnow acceptcustom_metadata: Option<&str>and forward it unchanged into each inneradd_documents/add_or_updatecall. This matches the doc comments that every task produced by the batch is tagged with the same metadata.Capacity reservation is still based on the document count (existing behavior); no new performance or correctness concerns introduced here.
Also applies to: 1770-1785
2232-2242: Helper and CSV/NDJSON tests give solid coverage of metadata propagationThe
expect_task_metadatahelper centralizes the assertion onTask::Succeeded { content }.custom_metadata, making the new tests concise and less error-prone.The
test_add_documents_ndjson,test_update_documents_ndjson,test_add_documents_csv, andtest_update_documents_csvtests validate that:
TaskInfo.custom_metadatareflects the provided metadata, and- The final
Taskretrieved viawait_for_completionpreserves the same metadata.This is exactly what we need to guard the new behavior on the streaming code paths.
Also applies to: 2413-2514
2579-2692:test_document_tasks_custom_metadatathoroughly exercises all main document task variantsThis test is a nice end-to-end check that
custom_metadataflows correctly through:
add_documentsdelete_documentadd_or_updatedelete_documentsdelete_documents_with(viaDocumentDeletionQuery)delete_all_documentsAsserting both
TaskInfo.custom_metadataand theTask’scontent.custom_metadataviaexpect_task_metadatagives good confidence that the SDK is correctly wiring the metadata end-to-end for the primary document operations.
|
@kumarUjjawal sorry can you rebase your PR? Or updated it with |
0fad2af to
aefd375
Compare
aefd375 to
7288f92
Compare
Should pass now |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/documents.rs (1)
415-427: Consider adding documentation for the new methodThe new
execute_with_custom_metadatamethod is a useful addition that allows passing custom metadata for deletion tasks. However, it lacks a documentation comment explaining its purpose and usage.📝 Suggested documentation
pub async fn execute<T: DeserializeOwned + 'static>(&self) -> Result<TaskInfo, Error> { self.execute_with_custom_metadata::<T>(None).await } - /// Same as [`DocumentDeletionQuery::execute`] but allows passing `custom_metadata` for the created task. + /// Execute the document deletion query with optional custom metadata. + /// + /// This method is similar to [`execute`](DocumentDeletionQuery::execute), but allows + /// attaching custom metadata to the deletion task. The metadata will be included in the + /// resulting [`TaskInfo`] and can be used to track or categorize tasks. + /// + /// # Arguments + /// + /// * `custom_metadata` - Optional metadata string to attach to the task + /// + /// # Example + /// + /// ```no_run + /// # use meilisearch_sdk::{client::*, indexes::*, documents::*}; + /// # let client = Client::new("http://localhost:7700", Some("masterKey")).unwrap(); + /// # let index = client.index("movies"); + /// let mut query = DocumentDeletionQuery::new(&index); + /// query.with_filter("year < 2000"); + /// let task = query.execute_with_custom_metadata::<()>(Some("cleanup-old-movies")).await.unwrap(); + /// ``` pub async fn execute_with_custom_metadata<T: DeserializeOwned + 'static>( &self, custom_metadata: Option<&'a str>, ) -> Result<TaskInfo, Error> {src/indexes.rs (1)
2579-2692: Comprehensive test coverage for metadata propagation.The test
test_document_tasks_custom_metadatathoroughly validates metadata through the full task lifecycle for key operations: add, update, delete single, delete batch, delete with filter, and delete all.Consider adding explicit tests for
add_documents_in_batchesandupdate_documents_in_batcheswith metadata to verify that each batch task receives the metadata string. Currently, these are only implicitly covered.🔎 Example test addition
// Test batch operations with metadata let batch_tasks = index .add_documents_in_batches( &[ SimpleDocument { id: 10, name: "ten" }, SimpleDocument { id: 11, name: "eleven" }, ], Some(1), // batch_size = 1 to create multiple tasks Some("id"), Some("batch-meta"), ) .await?; for task_info in &batch_tasks { assert_eq!(task_info.custom_metadata.as_deref(), Some("batch-meta")); }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
examples/cli-app-with-awc/src/main.rsexamples/cli-app/src/main.rsexamples/web_app_graphql/src/graphql_schema/users/query/search.rssrc/client.rssrc/documents.rssrc/indexes.rssrc/lib.rssrc/search.rssrc/task_info.rssrc/tasks.rs
🚧 Files skipped from review as they are similar to previous changes (3)
- src/tasks.rs
- examples/cli-app-with-awc/src/main.rs
- examples/cli-app/src/main.rs
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-12T13:28:23.700Z
Learnt from: LukasKalbertodt
Repo: meilisearch/meilisearch-rust PR: 625
File: src/search.rs:368-370
Timestamp: 2025-06-12T13:28:23.700Z
Learning: In the Meilisearch Rust client, `SearchQuery` serializes its per-query federation settings under the key `federationOptions`; only the top-level multi-search parameter is named `federation`.
Applied to files:
src/client.rs
🧬 Code graph analysis (3)
src/search.rs (1)
src/client.rs (4)
None(1541-1541)None(1584-1584)None(1587-1587)None(1682-1682)
src/indexes.rs (2)
src/documents.rs (7)
new(89-94)new(218-228)new(400-405)index(62-64)index(161-161)index(383-383)index(544-544)src/request.rs (1)
query(39-47)
src/client.rs (1)
src/batches.rs (3)
None(141-141)None(169-169)None(193-193)
⏰ 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 (23)
examples/web_app_graphql/src/graphql_schema/users/query/search.rs (1)
27-27: LGTM: Consistent API updateBoth call sites correctly updated to pass
Nonefor the newcustom_metadataparameter.Also applies to: 36-36
src/lib.rs (1)
37-37: Doctest examples updated correctlyThe doctest examples have been updated to include the new
custom_metadataparameter (passingNone). The examples remain valid and will continue to pass.Also applies to: 189-189
src/task_info.rs (3)
17-17: New field added to TaskInfoThe
custom_metadatafield is properly added as an optional string. The field will be populated from JSON responses containingcustomMetadata(camelCase).
114-141: Good test coverage for custom_metadata deserializationThe test properly verifies that:
- JSON with
"customMetadata": "batch-1"deserializes correctly- The field is accessible as
custom_metadatain Rust- The assertion correctly validates the value
65-65: Doctest and test updated correctlyCall sites updated to pass
Nonefor the newcustom_metadataparameter.Also applies to: 160-160
src/search.rs (2)
976-976: Doctest updated correctlyThe facet search example has been updated to pass
Nonefor the newcustom_metadataparameter in theadd_or_replacecall.
1237-1237: Test setup functions updated consistentlyBoth
setup_test_indexandsetup_test_video_indexhelper functions have been updated to passNonefor the newcustom_metadataparameter inadd_documentscalls.Also applies to: 1288-1288
src/client.rs (3)
171-171: Multi-search example updated correctlyThe doctest example for multi-search has been updated to pass
Nonefor the newcustom_metadataparameter.
912-912: Doctest examples updated consistentlyBoth the
wait_for_taskandget_taskexamples have been updated to passNonefor the newcustom_metadataparameter.Also applies to: 964-964
1635-1635: Test updated correctlyThe
test_swapping_two_indexestest has been updated to passNonefor the newcustom_metadataparameter in bothadd_documentscalls.Also applies to: 1646-1646
src/documents.rs (2)
144-144: Doctest updated correctlyThe example for
DocumentQuery::executehas been updated to passNonefor the newcustom_metadataparameter.
488-488: Test helper and calls updated correctlyThe
setup_test_indexhelper function anddelete_documents_withcalls have been updated to passNonefor the newcustom_metadataparameter.Also applies to: 540-540, 569-569
src/indexes.rs (11)
80-103: LGTM!The
DocumentTaskQuerystruct is well-designed with appropriate serde attributes for optional field serialization. The two constructors (newfor operations requiring primary_key,with_metadatafor delete operations) provide a clean API.
647-666: LGTM!The method signature and implementation correctly propagate the
custom_metadataparameter throughDocumentTaskQueryto the HTTP request.
706-729: LGTM!Correctly propagates
custom_metadatathroughDocumentTaskQueryfor stream requests.
1118-1131: LGTM!All delete methods correctly use
DocumentTaskQuery::with_metadata()to propagate custom metadata without a primary key. The implementation is consistent acrossdelete_all_documents,delete_document,delete_documents, anddelete_documents_with.Also applies to: 1168-1185, 1225-1242, 1285-1302
1674-1689: LGTM!The batch methods correctly propagate
custom_metadatato each sub-task. The documentation at lines 1673 and 1770 appropriately notes that the same metadata tags every task in a batch.Also applies to: 1771-1786
2232-2242: LGTM!The
expect_task_metadatahelper function is well-designed for validating metadata in tests. It correctly handles the succeeded task case and provides a clear panic message for debugging.
600-602: LGTM!The documentation clearly explains the purpose of
custom_metadataand its visibility through/tasksor webhooks.
780-793: LGTM!The NDJSON and CSV helper methods correctly forward
custom_metadatato their underlying unchecked payload implementations.Also applies to: 833-846, 885-893, 932-940
994-1013: LGTM!The
add_or_updateandadd_or_update_unchecked_payloadmethods correctly mirror theiradd_or_replacecounterparts with proper metadata propagation.Also applies to: 1055-1078
2320-2361: LGTM!The
test_update_document_jsontest correctly passesNonefor the newcustom_metadataparameter, maintaining backward compatibility testing.
647-652: Breaking API changes present - version requirement unverified.These method signature changes (adding
custom_metadata: Option<&str>) do introduce breaking changes for existing SDK consumers, as confirmed by modifications acrossadd_or_replace,add_or_update,delete_all_documents,delete_document,delete_documents, anddelete_documents_with.However, verification could not confirm:
- The specific Meilisearch v1.26 requirement claim; the README only states general v1.x compatibility
- Whether issue #733 directly addresses this change
- Existence of migration guidance or version-specific documentation
Recommend verifying the Meilisearch server version requirement and updating documentation accordingly if this requires v1.26+ specifically.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/tasks.rs (1)
165-186: Task structs extended withcustom_metadatacleanlyAdding
custom_metadata: Option<String>toSucceededTask(and similarly inEnqueuedTask/ProcessingTask) is backward compatible with existing deserialization and pattern matches, and fits the camelCase wire format. Consider adding a short doc comment explaining it carries the user‑suppliedcustomMetadatafrom the task payload, but this is optional.src/documents.rs (1)
415-427: Newexecute_with_custom_metadatanicely extends deletion without breaking callers
DocumentDeletionQuery::executenow simply forwards toexecute_with_custom_metadata::<T>(None), and the new method passescustom_metadatathrough toIndex::delete_documents_with. The reuse of'afor the metadata reference is compatible with howDocumentDeletionQueryis created.Only minor note (for a future breaking release): the generic
Tbound on both methods is now unused and could be dropped then to simplify the API.src/indexes.rs (1)
2322-2692:test_document_tasks_custom_metadatathoroughly exercises document-task metadataThe
test_document_tasks_custom_metadatacase covers all major document operations:
add_documents,add_or_update(single and multi-doc),delete_document,delete_documents(batch),delete_documents_with(filter),delete_all_documents,and checks both
TaskInfo.custom_metadataat submission time andTask::Succeeded’scontent.custom_metadataafterwait_for_completion. Combined withexpect_task_metadata, this is a solid regression suite for the new feature.Only optional thought: if you want parity, you could add a tiny assertion for metadata on tasks produced by the batch helpers (
add_documents_in_batches/update_documents_in_batches) in a follow-up, but the core feature is already well covered.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
README.mdexamples/cli-app-with-awc/src/main.rsexamples/cli-app/src/main.rsexamples/web_app_graphql/src/graphql_schema/users/query/search.rssrc/client.rssrc/documents.rssrc/indexes.rssrc/lib.rssrc/search.rssrc/task_info.rssrc/tasks.rs
✅ Files skipped from review due to trivial changes (1)
- README.md
🚧 Files skipped from review as they are similar to previous changes (4)
- src/task_info.rs
- src/search.rs
- examples/web_app_graphql/src/graphql_schema/users/query/search.rs
- src/lib.rs
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-12T13:28:23.700Z
Learnt from: LukasKalbertodt
Repo: meilisearch/meilisearch-rust PR: 625
File: src/search.rs:368-370
Timestamp: 2025-06-12T13:28:23.700Z
Learning: In the Meilisearch Rust client, `SearchQuery` serializes its per-query federation settings under the key `federationOptions`; only the top-level multi-search parameter is named `federation`.
Applied to files:
src/client.rs
🧬 Code graph analysis (5)
examples/cli-app/src/main.rs (1)
src/client.rs (4)
None(1541-1541)None(1584-1584)None(1587-1587)None(1682-1682)
src/client.rs (1)
src/batches.rs (3)
None(141-141)None(169-169)None(193-193)
src/tasks.rs (1)
src/client.rs (4)
None(1541-1541)None(1584-1584)None(1587-1587)None(1682-1682)
examples/cli-app-with-awc/src/main.rs (1)
src/client.rs (4)
None(1541-1541)None(1584-1584)None(1587-1587)None(1682-1682)
src/indexes.rs (1)
src/request.rs (1)
query(39-47)
⏰ 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 (13)
examples/cli-app-with-awc/src/main.rs (1)
186-195: Callsite correctly updated for newcustom_metadataargumentPassing
Noneas the new third parameter matches the updatedadd_or_update(&self, docs, primary_key, custom_metadata)signature; no behavior change in the example.examples/cli-app/src/main.rs (1)
110-118: Example aligned with extendedadd_or_updateAPIThe extra
Noneargument is correctly wired ascustom_metadatafor the updatedadd_or_updatesignature; example remains behaviorally identical.src/tasks.rs (3)
194-230: Enqueued/Processing task metadata field matches the rest of the modelThe new
custom_metadata: Option<String>onEnqueuedTaskandProcessingTaskmatches the field added onSucceededTaskand whatTaskInfoexposes, so tasks from/taskswill consistently surface per‑task metadata across all statuses.
301-308: Doc example updated for newadd_documentssignatureThe doctest now uses
add_documents(&[..], None, None), matching the new(primary_key, custom_metadata)tail parameters; good to keep examples in sync with the public API.
946-964: Testtest_wait_for_task_with_argscorrectly adapted to new APIThe additional
Noneargument onadd_documentsaligns with the newcustom_metadataparameter and keeps the test logic unchanged.src/client.rs (2)
167-191: Doctest callsites now match extended Index document APIsThe examples for multi-search and client‑level
wait_for_tasknow invokeadd_or_replace/add_documentswith an extra trailingNoneforcustom_metadata, which matches the new Index method signatures and keeps the sample behavior intact.
963-965: Tests correctly adjusted fordelete_all_documentsandadd_documentssignatures
index.delete_all_documents(None)now passescustom_metadataexplicitly.add_documentsinvocations intest_swapping_two_indexesuse the new(primary_key, custom_metadata)parameter list.These keep the tests compiling and semantically equivalent with the previous behavior (no metadata attached).
Also applies to: 1629-1647
src/documents.rs (2)
139-146: Doctest updated to newadd_or_replacesignatureThe example now calls
add_or_replace(&[..], None, None), lining up with the extended(primary_key, custom_metadata)parameters without changing behavior.
467-571: Test helpers and delete-with-filter tests correctly use new metadata parameter
setup_test_indexnow callsadd_documents(&[..], None, None).- Both
test_delete_documents_withandtest_delete_documents_with_filter_not_filterablepassNoneintodelete_documents_with(&query, None).This keeps the tests exercising the same behavior while aligning with the new signature that allows optional
custom_metadata.src/indexes.rs (4)
80-104:DocumentTaskQuerycentralizesprimaryKey/customMetadataquery handlingIntroducing
DocumentTaskQuery<'a>and using it as thequeryfor all document‑mutating endpoints (add_or_replace, add_documents, add_or_update, and_unchecked_payload/NDJSON/CSV variants) is a clean way to keepprimary_keyandcustom_metadatawiring consistent. The camelCase rename plusskip_serializing_if = "Option::is_none"matches the expected wire format and avoids stray query parameters when both areNone.Type usage with
Method::Post/stream_requestis correct, and the newcustom_metadata: Option<&str>parameters on the public APIs are threaded through everywhere.Also applies to: 647-741, 706-729
1080-1291: Delete endpoints now properly support per-taskcustom_metadata
delete_all_documents,delete_document,delete_documents, anddelete_documents_withall now:
- Accept
custom_metadata: Option<&str>in their public signatures.- Build a
DocumentTaskQuery::with_metadata(custom_metadata)for the HTTP query.- Keep existing behavior for the request body and URL path unchanged.
This matches the server’s API expectations and ensures every deletion task can carry user‑defined metadata, consistent with the addition/update endpoints.
1673-1786: Batch helpers propagatecustom_metadataconsistentlyBoth
add_documents_in_batchesandupdate_documents_in_batchesnow acceptcustom_metadata: Option<&str>and pass it through toadd_documents/add_or_updatefor every chunk. This means each task created for a batch will share the same metadata string, which is exactly what the new doc comments describe.
2322-2514: CSV/NDJSON tests validate metadata propagation end-to-endThe new tests:
- Call
add_documents_ndjson/update_documents_ndjsonandadd_documents_csv/update_documents_csvwith non‑Nonemetadata strings.- Assert that
TaskInfo.custom_metadatais set correctly.- Await completion and use
expect_task_metadatato assert the resultingTask::Succeededcarries the samecustom_metadata.This gives strong coverage that the new query plumbing (
DocumentTaskQuery) and the task deserialization (Task/SucceededTask) are correctly wired together for streaming document formats as well.
|
Should use the local path? |
Yes, thank you! |
|
Also, tests are failing: https://github.com/meilisearch/meilisearch-rust/actions/runs/20579542524/job/59103940634?pr=736 |
Yeah the tests are failing becuase we are adding a new field which doesn't exist of the |
Pull Request
Related issue
Fixes #733
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
✏️ Tip: You can customize this high-level summary in your review settings.