Skip to content

Commit 554c6db

Browse files
authored
Merge pull request #87 from tharropoulos/retrieve-params
feat(document): add parameter support to document retrieval
2 parents 36b25b2 + 3ba2ef2 commit 554c6db

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/typesense/document.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
DeleteSingleDocumentParameters,
2727
DirtyValuesParameters,
2828
DocumentSchema,
29+
RetrieveParameters,
2930
)
3031

3132
if sys.version_info >= (3, 11):
@@ -67,7 +68,10 @@ def __init__(
6768
self.collection_name = collection_name
6869
self.document_id = document_id
6970

70-
def retrieve(self) -> TDoc:
71+
def retrieve(
72+
self,
73+
retrieve_parameters: typing.Union[RetrieveParameters, None] = None,
74+
) -> TDoc:
7175
"""
7276
Retrieve this specific document.
7377
@@ -78,6 +82,7 @@ def retrieve(self) -> TDoc:
7882
endpoint=self._endpoint_path,
7983
entity_type=typing.Dict[str, str],
8084
as_json=True,
85+
params=retrieve_parameters,
8186
)
8287
return response
8388

src/typesense/types/document.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,3 +889,16 @@ class DeleteResponse(typing.TypedDict):
889889
"""
890890

891891
num_deleted: int
892+
893+
894+
class RetrieveParameters(typing.TypedDict):
895+
"""
896+
Parameters for retrieving documents.
897+
898+
Attributes:
899+
include_fields (str): Fields to include in the retrieved documents.
900+
exclude_fields (str): Fields to exclude from the retrieved documents.
901+
"""
902+
903+
include_fields: typing.NotRequired[typing.Union[str, typing.List[str]]]
904+
exclude_fields: typing.NotRequired[typing.Union[str, typing.List[str]]]

0 commit comments

Comments
 (0)