The current type definitions for Highlight and HighlightExtended in document.py:725-750 do not match the Typesense 30.2 API response documented at https://typesense.org/docs/30.2/api/search.html.
Current definitions:
class Highlight(typing.TypedDict):
matched_tokens: typing.List[str]
snippet: str # singular, plain string
value: str
class HighlightExtended(Highlight):
field: str
class Hit(...):
highlights: typing.List[HighlightExtended]
highlight: typing.Dict[str, Highlight]
...
Issues where the shape is wrong for search result on multi-value / array fields (eg string[]):
- snippet vs snippets: The API returns snippets (a list of strings), not a singular snippet. Neither
Highlight nor HighlightExtended declare this field.
- indices is missing: The API returns an indices field (list of integers) indicating which array element(s) matched. Neither
Highlight nor HighlightExtended declare this field.
- matched_tokens is typed as
List[str] but should be List[List[str]]: Each element corresponds to a matched array slot and is itself a list of tokens.
- value placement: value (the full field value with highlights) appears in the highlight dict entries, but not necessarily in each highlights list item. Having it on
Highlight (which is used for both) conflates the two shapes.
The current type definitions for
HighlightandHighlightExtendedin document.py:725-750 do not match the Typesense 30.2 API response documented at https://typesense.org/docs/30.2/api/search.html.Current definitions:
Issues where the shape is wrong for search result on multi-value / array fields (eg
string[]):HighlightnorHighlightExtendeddeclare this field.HighlightnorHighlightExtendeddeclare this field.List[str]but should beList[List[str]]: Each element corresponds to a matched array slot and is itself a list of tokens.Highlight(which is used for both) conflates the two shapes.