Skip to content

feat: add support for alter schema drop vector index#1991

Open
antas-marcin wants to merge 2 commits into
bump-integration-tests-1.39from
alter-schema-drop-vector-index
Open

feat: add support for alter schema drop vector index#1991
antas-marcin wants to merge 2 commits into
bump-integration-tests-1.39from
alter-schema-drop-vector-index

Conversation

@antas-marcin

@antas-marcin antas-marcin commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add delete_vector_index(vector_name) method to collection config, allowing users to drop a named vector's index via DELETE /v1/schema/{className}/vectors/{vectorIndexName}/index
  • Follows the same pattern as the existing delete_property_index method
  • Includes both sync and async type stubs

Closes #1990

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds client support for dropping a named vector’s index via the schema REST endpoint, mirroring the existing “delete property index” capability in the collections config API.

Changes:

  • Added delete_vector_index(vector_name) to the collection config executor, issuing DELETE /v1/schema/{className}/vectors/{vectorIndexName}/index.
  • Added sync and async type stubs for delete_vector_index(...).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
weaviate/collections/config/executor.py Implements the new delete-vector-index operation via the config executor.
weaviate/collections/config/sync.pyi Exposes the new method in the sync config type stub.
weaviate/collections/config/async_.pyi Exposes the new method in the async config type stub.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread weaviate/collections/config/executor.py Outdated
Comment on lines +647 to +650
Raises:
weaviate.exceptions.WeaviateConnectionError: If the network connection to Weaviate fails.
weaviate.exceptions.UnexpectedStatusCodeError: If Weaviate reports a non-OK status.
weaviate.exceptions.WeaviateInvalidInputError: If the vector does not exist.
Comment on lines +662 to +664
def resp(res: Response) -> bool:
return res.status_code == 200

Comment on lines +665 to +671
return executor.execute(
response_callback=resp,
method=self._connection.delete,
path=path,
error_msg="Vector may not exist",
status_codes=_ExpectedStatusCodes(ok_in=[200], error="vector exists"),
)
Comment on lines +635 to +671
def delete_vector_index(
self,
vector_name: str,
) -> executor.Result[bool]:
"""Delete a vector index from the collection in Weaviate.

This is a destructive operation. The index will
need to be regenerated if you wish to use it again.

Args:
vector_name: The name of the vector whose index to delete.

Raises:
weaviate.exceptions.WeaviateConnectionError: If the network connection to Weaviate fails.
weaviate.exceptions.UnexpectedStatusCodeError: If Weaviate reports a non-OK status.
weaviate.exceptions.WeaviateInvalidInputError: If the vector does not exist.
"""
_validate_input(
[_ValidateArgument(expected=[str], name="vector_name", value=vector_name)]
)

path = (
f"/schema/{_capitalize_first_letter(self._name)}"
+ f"/vectors/{vector_name}"
+ "/index"
)

def resp(res: Response) -> bool:
return res.status_code == 200

return executor.execute(
response_callback=resp,
method=self._connection.delete,
path=path,
error_msg="Vector may not exist",
status_codes=_ExpectedStatusCodes(ok_in=[200], error="vector exists"),
)
@jfrancoa
jfrancoa changed the base branch from main to bump-integration-tests-1.39 July 22, 2026 11:25
@jfrancoa
jfrancoa force-pushed the alter-schema-drop-vector-index branch from d728dd9 to 7e5cd7f Compare July 22, 2026 11:25
@jfrancoa
jfrancoa requested a review from a team as a code owner July 22, 2026 11:25

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment on lines 283 to +287
vector_index_config = __get_vector_index_config(named_vector)
assert vector_index_config is not None
# A vector whose index was dropped with `collection.config.delete_vector_index` is
# returned as `vectorIndexType: "none"` without any `vectorIndexConfig`.
assert (
vector_index_config is not None
Comment on lines +39 to 42
NONE: The index of this vector has been dropped, see ``collection.config.delete_vector_index``.
The vector data is still stored, but it cannot be searched. This value is reported by the
server only, it cannot be used to configure a vector.
"""
antas-marcin and others added 2 commits July 22, 2026 14:06
Follow-up to the `delete_vector_index` support, addressing review findings.

After a successful drop, Weaviate keeps the vector in the schema as
`vectorIndexType: "none"` with no `vectorIndexConfig`. The client asserted that
every named vector has an index config, so `collection.config.get()` and
`client.collections.list_all()` raised `AssertionError` for every collection in
the cluster once any vector index had been dropped. `_NamedVectorConfig.
vector_index_config` is now optional, `VectorIndexType` gained a server-reported
`NONE` member and `to_dict()` round-trips it.

`collection.config.update()` on a dropped vector raised a bare
`KeyError: 'vectorIndexConfig'` from the schema merge. Both the current and the
deprecated merge paths now go through one helper that raises a
`WeaviateInvalidInputError` explaining that a dropped index cannot be re-created.

The docstring claimed the index could be regenerated and that a missing vector
raises `WeaviateInvalidInputError`. Neither is true: Weaviate rejects
re-creating a dropped index, and an unknown vector name comes back as a 422.
It now also documents that the endpoint is experimental and needs
`ENABLE_EXPERIMENTAL_ALTER_SCHEMA_DROP_VECTOR_INDEX_ENDPOINT=true`, that only
named vectors can be dropped, and that the drop is applied asynchronously. The
error message no longer blames a missing vector for what is usually a disabled
endpoint.

Tests: unit coverage for parsing, exporting and updating a dropped vector, mock
coverage for the request path and the disabled-endpoint response, and
integration coverage gated at 1.39.0. The CI compose file enables the
experimental endpoint; that flag can be dropped once 1.39.0 is GA.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jfrancoa
jfrancoa force-pushed the alter-schema-drop-vector-index branch from 4e2a580 to 2dbfaed Compare July 22, 2026 12:07
@bevzzz

bevzzz commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

thought: Do you think this PR could do with fewer tests? The new endpoint is very simple and it seems to me like one "happy path" test will catch most things.

Other tests verify Weaviate's behavior more than client's logic, and some may add up to 30s of pipeline time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for delete vector index operation

4 participants