Skip to content

Commit 99e958c

Browse files
antas-marcinjfrancoa
authored andcommitted
feat: add support for alter schema drop vector index
1 parent 3657487 commit 99e958c

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
@@ -631,3 +631,41 @@ def resp(res: Response) -> bool:
631631
error_msg="Property may not exist",
632632
status_codes=_ExpectedStatusCodes(ok_in=[200], error="property exists"),
633633
)
634+
635+
def delete_vector_index(
636+
self,
637+
vector_name: str,
638+
) -> executor.Result[bool]:
639+
"""Delete a vector index from the collection in Weaviate.
640+
641+
This is a destructive operation. The index will
642+
need to be regenerated if you wish to use it again.
643+
644+
Args:
645+
vector_name: The name of the vector whose index to delete.
646+
647+
Raises:
648+
weaviate.exceptions.WeaviateConnectionError: If the network connection to Weaviate fails.
649+
weaviate.exceptions.UnexpectedStatusCodeError: If Weaviate reports a non-OK status.
650+
weaviate.exceptions.WeaviateInvalidInputError: If the vector does not exist.
651+
"""
652+
_validate_input(
653+
[_ValidateArgument(expected=[str], name="vector_name", value=vector_name)]
654+
)
655+
656+
path = (
657+
f"/schema/{_capitalize_first_letter(self._name)}"
658+
+ f"/vectors/{vector_name}"
659+
+ "/index"
660+
)
661+
662+
def resp(res: Response) -> bool:
663+
return res.status_code == 200
664+
665+
return executor.execute(
666+
response_callback=resp,
667+
method=self._connection.delete,
668+
path=path,
669+
error_msg="Vector may not exist",
670+
status_codes=_ExpectedStatusCodes(ok_in=[200], error="vector exists"),
671+
)

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)