spring-projects/spring-ai · error · RuntimeException

Drop Index failed!

Error message

Drop Index failed!

What it means

dropCollection then drops the index on the collection and throws a plain RuntimeException("Drop Index failed!") if the dropIndex RPC returns an exception. The index removal on the Milvus server failed, blocking the subsequent dropCollection step.

Solutions

  1. Read the cause exception for the Milvus status code.
  2. Ensure releaseCollection succeeded before dropIndex.
  3. Handle/ignore 'index not found' cases and proceed to dropCollection.
  4. Verify connectivity and permissions on the Milvus server.
  5. Manually drop the index via Attu/CLI if the client state is stuck, then retry.

Example fix

// before
// dropIndex fails because collection was never released
// after
milvusClient.releaseCollection(ReleaseCollectionParam.newBuilder().withCollectionName(name).build());
milvusClient.dropIndex(DropIndexParam.newBuilder().withCollectionName(name).build());
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure the collection was released before dropping the index
// (releaseCollection must succeed first in the dropCollection flow)
milvusClient.releaseCollection(ReleaseCollectionParam.newBuilder().withCollectionName(collectionName).build());

Try / catch

try {
    // dropCollection flow invokes dropIndex internally
} catch (RuntimeException e) {
    String msg = e.getCause() != null ? e.getCause().getMessage() : e.getMessage();
    if (msg != null && msg.contains("index not found")) {
        // tolerate already-dropped index and continue
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Called from shouldFilterWithCustomMetadataFieldName or dropCollection flow when milvusClient.dropIndex fails: index does not exist, collection still loaded, connection failure, or insufficient permissions.

Common situations: Index already dropped by a prior failed run; collection not released first (release step failed silently upstream); Milvus version requiring released state before index drop.

Related errors


AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11). Data as JSON: /api/errors/e7157dee85d3b64d. Report an issue: GitHub.

Appendix: source

Thrown at vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStore.java:607

		}
		return OPENAI_EMBEDDING_DIMENSION_SIZE;
	}

	// used by the test as well
	void dropCollection() {

		R<RpcStatus> status = this.milvusClient
			.releaseCollection(ReleaseCollectionParam.newBuilder().withCollectionName(this.collectionName).build());

		if (status.getException() != null) {
			throw new RuntimeException("Release collection failed!", status.getException());
		}

		status = this.milvusClient
			.dropIndex(DropIndexParam.newBuilder().withCollectionName(this.collectionName).build());

		if (status.getException() != null) {
			throw new RuntimeException("Drop Index failed!", status.getException());
		}

		status = this.milvusClient.dropCollection(DropCollectionParam.newBuilder()
			.withDatabaseName(this.databaseName)
			.withCollectionName(this.collectionName)
			.build());

		if (status.getException() != null) {
			throw new RuntimeException("Drop Collection failed!", status.getException());
		}
	}

	@Override
	public org.springframework.ai.vectorstore.observation.VectorStoreObservationContext.Builder createObservationContextBuilder(
			String operationName) {

		return VectorStoreObservationContext.builder(VectorStoreProvider.MILVUS.value(), operationName)
			.collectionName(this.collectionName)

View on GitHub (pinned to 98a7beda4f)