supabase / vecs

Postgres/pgvector Python Client
https://supabase.github.io/vecs/latest
Apache License 2.0
219 stars 33 forks source link

feat: add ability to delete by filtering metadata only #57

Closed jeanmaried closed 10 months ago

jeanmaried commented 11 months ago

What kind of change does this PR introduce?

Feature

What is the current behavior?

I need to be able to delete vectors based solely on their metadata but currently the only way to do so is to already have the ids.

What is the new behavior?

I added 2 methods as suggestions. Option #1: add a delete_by_metadata Option #2: delete_vectors (temporary name) a suggestion for updating the current delete function to allow optionally passing the ids or metdata (one or the other).

Please let me know which is an acceptable approach and if there are any objections to having this capability.

olirice commented 11 months ago

Deleting by metadata sounds reasonable. I think the right way to approach it would be to overload the existing delete method in a backwards compatible way

Something like:

From

def delete(self, ids: Iterable[str]) -> List[str]:

To

def delete(self, ids: Optional[Iterable[str]] = None, filters: Optional[Metadata] = None) -> List[str]:

where filters goes through the same build_filter logic as query.

jeanmaried commented 11 months ago

@olirice thank you, I updated the method and the docs.

olirice commented 10 months ago

very nice, thank you!