Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/typesense/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
DeleteSingleDocumentParameters,
DirtyValuesParameters,
DocumentSchema,
RetrieveParameters,
)

if sys.version_info >= (3, 11):
Expand Down Expand Up @@ -67,7 +68,10 @@ def __init__(
self.collection_name = collection_name
self.document_id = document_id

def retrieve(self) -> TDoc:
def retrieve(
self,
retrieve_parameters: typing.Union[RetrieveParameters, None] = None,
) -> TDoc:
"""
Retrieve this specific document.

Expand All @@ -78,6 +82,7 @@ def retrieve(self) -> TDoc:
endpoint=self._endpoint_path,
entity_type=typing.Dict[str, str],
as_json=True,
params=retrieve_parameters,
)
return response

Expand Down
13 changes: 13 additions & 0 deletions src/typesense/types/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,3 +889,16 @@ class DeleteResponse(typing.TypedDict):
"""

num_deleted: int


class RetrieveParameters(typing.TypedDict):
"""
Parameters for retrieving documents.

Attributes:
include_fields (str): Fields to include in the retrieved documents.
exclude_fields (str): Fields to exclude from the retrieved documents.
"""

include_fields: typing.NotRequired[typing.Union[str, typing.List[str]]]
exclude_fields: typing.NotRequired[typing.Union[str, typing.List[str]]]