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.
Currently, the
PGVectorclass only allows deleting vectors by specifying their IDs through thedeleteandadeletemethods. There is no built-in functionality to delete vectors based on metadata filters.Proposed Solution
Modify the
deleteandadeletemethods to accept an optionalfilterparameter. 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_clausemethod to generate the appropriate SQLAlchemy where clauses.Example Usage
Benefits
Additional Context
_create_filter_clausemethod correctly handles all supported operators and edge cases.