feat: support retrieveVectors in getDocument - #920
Conversation
The get-one-document endpoint accepts a `retrieveVectors` query parameter to include each document's vector data (the `_vectors` field), but `getDocument` had no way to set it — only `getDocuments` did, via `DocumentsQuery`. Add a `retrieveVectors` parameter to `getDocument`, forwarded as a query parameter. Adds an integration test mirroring the `getDocuments` vector test. Closes meilisearch#809
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesgetDocument retrieveVectors support
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #920 +/- ##
==========================================
- Coverage 89.78% 88.40% -1.39%
==========================================
Files 59 92 +33
Lines 1449 1932 +483
==========================================
+ Hits 1301 1708 +407
- Misses 148 224 +76 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
The get-one-document endpoint accepts a
retrieveVectorsquery parameter (toinclude each document's vector data in the
_vectorsfield), butIndex::getDocument()had no way to set it — onlygetDocuments()did, throughDocumentsQuery. This closes that gap. Closes #809.Changes
getDocument(string|int $documentId, ?array $fields = null, bool $retrieveVectors = false):when
true, the request now sendsretrieveVectors=true. New optionalparameter, so it's non-breaking for existing callers.
testGetDocumentWithVector) mirroring the existingtestGetDocumentsWithVector, asserting_vectorsis absent by default andpresent when
retrieveVectorsis enabled.Overview
This PR adds support for the
retrieveVectorsquery parameter to thegetDocument()method in the Meilisearch PHP SDK, enabling retrieval of vector data for individual documents through the single-document endpoint. Previously, this functionality was only available through thegetDocuments()method.Changes
API Method Update
getDocument()signature to accept an optional$retrieveVectorsboolean parameter (defaults tofalsefor backward compatibility)$retrieveVectorsistrue, the method includesretrieveVectors=truein the query parameters sent to the/documents/{id}endpointTest Coverage
testGetDocumentWithVector()that verifies:_vectorsfield is absent from the response by default_vectorsfield is included whenretrieveVectorsis enabledVECTOR_MOVIESdatasetImpact
This change brings feature parity between the single-document and multi-document retrieval methods, allowing developers to retrieve vector data via
getDocument()just as they can withgetDocuments(). Since the new parameter is optional with a default value offalse, this is a non-breaking change for existing code.