Skip to content

Add removeDocument() method to EmbeddingsStoreInterface #132

Open

Description

@wachterjohannes

The EmbeddingsStoreInterface currently supports adding documents and similarity search, but lacks a method to remove/delete documents from the vector store. This is needed for complete CRUD operations.

Proposed API

interface EmbeddingsStoreInterface
{
    public function addDocument(EmbeddingInterface $embedding): void;

    /**
     * @param EmbeddingInterface[] $embeddings
     */
    public function addDocuments(array $embeddings): void;

    /**
     * Remove a document and all its chunks from the vector store.
     * 
     * @param string $identifier The document identifier (e.g., "doc-123" will remove "doc-123-chunk-0", "doc-123-chunk-1", etc.)
     */
    public function removeDocument(string $identifier): void;

    /**
     * @param float[] $vector
     * @param array<string, mixed> $additionalArguments
     *
     * @return EmbeddingInterface[]
     */
    public function similaritySearch(array $vector, int $k = 4, array $additionalArguments = []): array;
}

Implementation Notes

For Qdrant (QdrantEmbeddingsStore):

  • Use Qdrant's deleteByFilter() method with a filter matching all points where the identifier starts with the document ID
  • Alternative: Use scroll() to find all point IDs matching the pattern, then delete() them

Use Case

When documents are updated or removed from a system, their embeddings should also be removed from the vector store to keep the data synchronized and avoid outdated search results.

Affected Packages

  • modelflow-ai/embeddings - Interface definition
  • modelflow-ai/qdrant-embeddings-store - Qdrant implementation
  • Any other store implementations

Activity

  1. added this to the 0.4 milestone on Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions