@@ -1288,12 +1288,22 @@ async def search_similar_documents(
12881288
12891289 return SimilarSearchResults [self .hits_type ](** response .json ()) # type: ignore[name-defined]
12901290
1291- async def get_document (self , document_id : str ) -> JsonDict :
1291+ async def get_document (
1292+ self ,
1293+ document_id : str ,
1294+ * ,
1295+ fields : list [str ] | None = None ,
1296+ retrieve_vectors : bool = False ,
1297+ ) -> JsonDict :
12921298 """Get one document with given document identifier.
12931299
12941300 Args:
12951301 document_id: Unique identifier of the document.
1296-
1302+ fields: Document attributes to show. If this value is None then all
1303+ attributes are retrieved. Defaults to None.
1304+ retrieve_vectors: If set to True the embedding vectors will be returned with the document.
1305+ Defaults to False. Note: This parameter can only be
1306+ used with Meilisearch >= v1.13.0
12971307 Returns:
12981308 The document information
12991309
@@ -1307,7 +1317,16 @@ async def get_document(self, document_id: str) -> JsonDict:
13071317 >>> index = client.index("movies")
13081318 >>> document = await index.get_document("1234")
13091319 """
1310- response = await self ._http_requests .get (f"{ self ._documents_url } /{ document_id } " )
1320+ parameters : JsonDict = {}
1321+
1322+ if fields :
1323+ parameters ["fields" ] = "," .join (fields )
1324+ if retrieve_vectors :
1325+ parameters ["retrieveVectors" ] = "true"
1326+
1327+ url = _build_encoded_url (f"{ self ._documents_url } /{ document_id } " , parameters )
1328+
1329+ response = await self ._http_requests .get (url )
13111330
13121331 return response .json ()
13131332
@@ -1318,6 +1337,7 @@ async def get_documents(
13181337 limit : int = 20 ,
13191338 fields : list [str ] | None = None ,
13201339 filter : Filter | None = None ,
1340+ retrieve_vectors : bool = False ,
13211341 ) -> DocumentsInfo :
13221342 """Get a batch documents from the index.
13231343
@@ -1328,6 +1348,9 @@ async def get_documents(
13281348 attributes are retrieved. Defaults to None.
13291349 filter: Filter value information. Defaults to None. Note: This parameter can only be
13301350 used with Meilisearch >= v1.2.0
1351+ retrieve_vectors: If set to True the vectors will be returned with each document.
1352+ Defaults to False. Note: This parameter can only be
1353+ used with Meilisearch >= v1.13.0
13311354
13321355 Returns:
13331356 Documents info.
@@ -1348,6 +1371,9 @@ async def get_documents(
13481371 "limit" : limit ,
13491372 }
13501373
1374+ if retrieve_vectors :
1375+ parameters ["retrieveVectors" ] = "true"
1376+
13511377 if not filter :
13521378 if fields :
13531379 parameters ["fields" ] = "," .join (fields )
@@ -5470,12 +5496,22 @@ def search_similar_documents(
54705496
54715497 return SimilarSearchResults [self .hits_type ](** response .json ()) # type: ignore[name-defined]
54725498
5473- def get_document (self , document_id : str ) -> JsonDict :
5499+ def get_document (
5500+ self ,
5501+ document_id : str ,
5502+ * ,
5503+ fields : list [str ] | None = None ,
5504+ retrieve_vectors : bool = False ,
5505+ ) -> JsonDict :
54745506 """Get one document with given document identifier.
54755507
54765508 Args:
54775509 document_id: Unique identifier of the document.
5478-
5510+ fields: Document attributes to show. If this value is None then all
5511+ attributes are retrieved. Defaults to None.
5512+ retrieve_vectors: If set to True the embedding vectors will be returned with the document.
5513+ Defaults to False. Note: This parameter can only be
5514+ used with Meilisearch >= v1.13.0
54795515 Returns:
54805516 The document information
54815517
@@ -5489,8 +5525,16 @@ def get_document(self, document_id: str) -> JsonDict:
54895525 >>> index = client.index("movies")
54905526 >>> document = index.get_document("1234")
54915527 """
5492- response = self ._http_requests .get (f"{ self ._documents_url } /{ document_id } " )
5528+ parameters : JsonDict = {}
5529+
5530+ if fields :
5531+ parameters ["fields" ] = "," .join (fields )
5532+ if retrieve_vectors :
5533+ parameters ["retrieveVectors" ] = "true"
54935534
5535+ url = _build_encoded_url (f"{ self ._documents_url } /{ document_id } " , parameters )
5536+
5537+ response = self ._http_requests .get (url )
54945538 return response .json ()
54955539
54965540 def get_documents (
@@ -5500,6 +5544,7 @@ def get_documents(
55005544 limit : int = 20 ,
55015545 fields : list [str ] | None = None ,
55025546 filter : Filter | None = None ,
5547+ retrieve_vectors : bool = False ,
55035548 ) -> DocumentsInfo :
55045549 """Get a batch documents from the index.
55055550
@@ -5510,6 +5555,9 @@ def get_documents(
55105555 attributes are retrieved. Defaults to None.
55115556 filter: Filter value information. Defaults to None. Note: This parameter can only be
55125557 used with Meilisearch >= v1.2.0
5558+ retrieve_vectors: If set to True the vectors will be returned with each document.
5559+ Defaults to False. Note: This parameter can only be
5560+ used with Meilisearch >= v1.13.0
55135561
55145562 Returns:
55155563 Documents info.
@@ -5530,6 +5578,9 @@ def get_documents(
55305578 "limit" : limit ,
55315579 }
55325580
5581+ if retrieve_vectors :
5582+ parameters ["retrieveVectors" ] = "true"
5583+
55335584 if not filter :
55345585 if fields :
55355586 parameters ["fields" ] = "," .join (fields )
0 commit comments