Skip to content

Commit 58df75e

Browse files
authored
Merge pull request #79 from tharropoulos/hnsw_params
feat(types): add hnsw parameters to field schema
2 parents 1208b64 + 1df5fe0 commit 58df75e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ exclude = .git,__pycache__,venv,.eggs,*.egg,src/typesense/__init__.py
2323
ignore = Q000, WPS602, WPS432, WPS305, WPS221, WPS230, WPS234, WPS433, WPS440, W503, WPS331, WPS306, WPS237, WPS202, RST301, RST306, WPS214, WPS235, WPS226, WPS337, WPS320, F821, WPS201
2424
per-file-ignores =
2525
tests/*.py: S101, WPS226, WPS118, WPS202, WPS204, WPS218, WPS211, WPS604, WPS431, WPS210, WPS201, WPS437
26-
src/typesense/types/*.py: B950, WPS215, WPS111, WPS462, WPS322, WPS428, WPS114, WPS110, WPS202
26+
src/typesense/types/*.py: B950, WPS215, WPS111, WPS462, WPS322, WPS428, WPS114, WPS110, WPS202, WPS115
2727
src/typesense/documents.py: WPS320, E704, D102, WPS428, WPS220
2828
src/typesense/stemming_dictionaries.py: WPS320, E704, D102, WPS428, WPS220
2929
src/typesense/api_call.py: WPS110, WPS211

src/typesense/types/collection.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@
3636
Locales = typing.Literal["ja", "zh", "ko", "th", "el", "ru", "rs", "uk", "be", ""]
3737

3838

39+
class HNSWParamsSchema(typing.TypedDict):
40+
"""
41+
The schema for the HNSW parameters in the CollectionFieldSchema.
42+
43+
Attributes:
44+
M (int): The number of bi-directional links created for every new element.
45+
ef_construction (int): The size of the dynamic list for the nearest neighbors.
46+
"""
47+
48+
M: typing.NotRequired[int]
49+
ef_construction: typing.NotRequired[int]
50+
51+
3952
class CollectionFieldSchema(typing.Generic[_TType], typing.TypedDict, total=False):
4053
"""
4154
CollectionFieldSchema represents the schema of a field in a collection.
@@ -70,6 +83,7 @@ class CollectionFieldSchema(typing.Generic[_TType], typing.TypedDict, total=Fals
7083
symbols_to_index: typing.NotRequired[typing.List[str]]
7184
token_separators: typing.NotRequired[typing.List[str]]
7285
num_dim: typing.NotRequired[float]
86+
hnsw_params: typing.NotRequired[HNSWParamsSchema]
7387
range_index: typing.NotRequired[bool]
7488
index: typing.NotRequired[bool]
7589
vec_dist: typing.NotRequired[typing.Union[typing.Literal["cosine", "ip"], str]]

0 commit comments

Comments
 (0)