Skip to content

Commit 255d0b0

Browse files
committed
[FIX]: update Highlight type definition to support array fields and optional attributes
1 parent e863b44 commit 255d0b0

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/typesense/types/document.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,14 +727,18 @@ class Highlight(typing.TypedDict):
727727
Schema for highlighting search results.
728728
729729
Attributes:
730-
matched_tokens (list[str]): List of matched tokens.
730+
matched_tokens (list[str] | list[list[str]]): List of matched tokens.
731731
snippet (str): Snippet of the matched tokens.
732+
snippets (list[str]): Snippets of the matched tokens (for array fields).
733+
indices (list[int]): Indices of the matched tokens (for array fields).
732734
value (str): Value of the matched tokens.
733735
"""
734736

735-
matched_tokens: typing.List[str]
736-
snippet: str
737-
value: str
737+
matched_tokens: typing.Union[typing.List[str], typing.List[typing.List[str]]]
738+
snippet: typing.NotRequired[str]
739+
snippets: typing.NotRequired[typing.List[str]]
740+
indices: typing.NotRequired[typing.List[int]]
741+
value: typing.NotRequired[str]
738742

739743

740744
class HighlightExtended(Highlight):

0 commit comments

Comments
 (0)