Skip to content

Commit 66e5b85

Browse files
antas-marcinjfrancoa
authored andcommitted
feat: add support for alter schema drop vector index
1 parent 736a7cd commit 66e5b85

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

weaviate/collections/config/async_.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,4 @@ class _ConfigCollectionAsync(_ConfigCollectionExecutor[ConnectionAsync]):
9090
self, *, vector_config: Union[_VectorConfigCreate, List[_VectorConfigCreate]]
9191
) -> None: ...
9292
async def delete_property_index(self, property_name: str, index_name: IndexName) -> bool: ...
93+
async def delete_vector_index(self, vector_name: str) -> bool: ...

weaviate/collections/config/executor.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,3 +666,41 @@ def resp(res: Response) -> bool:
666666
error_msg="Property may not exist",
667667
status_codes=_ExpectedStatusCodes(ok_in=[200], error="property exists"),
668668
)
669+
670+
def delete_vector_index(
671+
self,
672+
vector_name: str,
673+
) -> executor.Result[bool]:
674+
"""Delete a vector index from the collection in Weaviate.
675+
676+
This is a destructive operation. The index will
677+
need to be regenerated if you wish to use it again.
678+
679+
Args:
680+
vector_name: The name of the vector whose index to delete.
681+
682+
Raises:
683+
weaviate.exceptions.WeaviateConnectionError: If the network connection to Weaviate fails.
684+
weaviate.exceptions.UnexpectedStatusCodeError: If Weaviate reports a non-OK status.
685+
weaviate.exceptions.WeaviateInvalidInputError: If the vector does not exist.
686+
"""
687+
_validate_input(
688+
[_ValidateArgument(expected=[str], name="vector_name", value=vector_name)]
689+
)
690+
691+
path = (
692+
f"/schema/{_capitalize_first_letter(self._name)}"
693+
+ f"/vectors/{vector_name}"
694+
+ "/index"
695+
)
696+
697+
def resp(res: Response) -> bool:
698+
return res.status_code == 200
699+
700+
return executor.execute(
701+
response_callback=resp,
702+
method=self._connection.delete,
703+
path=path,
704+
error_msg="Vector may not exist",
705+
status_codes=_ExpectedStatusCodes(ok_in=[200], error="vector exists"),
706+
)

weaviate/collections/config/sync.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,4 @@ class _ConfigCollection(_ConfigCollectionExecutor[ConnectionSync]):
8888
self, *, vector_config: Union[_VectorConfigCreate, List[_VectorConfigCreate]]
8989
) -> None: ...
9090
def delete_property_index(self, property_name: str, index_name: IndexName) -> bool: ...
91+
def delete_vector_index(self, vector_name: str) -> bool: ...

0 commit comments

Comments
 (0)