Skip to content

Feature Request: Support Deleting Vectors by Metadata in PGVector Class #127

Open
@shamspias

Description

@shamspias

Currently, the PGVector class only allows deleting vectors by specifying their IDs through the delete and adelete methods. There is no built-in functionality to delete vectors based on metadata filters.

Proposed Solution

Modify the delete and adelete methods to accept an optional filter parameter. This parameter would allow users to specify conditions based on metadata fields, enabling the deletion of vectors that match these conditions. Utilize the existing _create_filter_clause method to generate the appropriate SQLAlchemy where clauses.

Example Usage

# Delete vectors where the 'category' metadata field equals 'news'
vector_store.delete(filter={"category": {"$eq": "news"}})

Benefits

  • Enhanced Functionality: Allows deletion of vectors based on metadata, improving data management capabilities.
  • Flexibility: Supports complex queries using existing filter mechanisms.
  • Backward Compatibility: The existing functionality of deleting by IDs remains unaffected.

Additional Context

  • Ensure that the _create_filter_clause method correctly handles all supported operators and edge cases.
  • Maintain consistency with the rest of the class's API design.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions