Delete with metadata filters does not work

Hi, I’m trying to use the delete method with namespace and metadata filters in the Python library and nothing happens. Here’s what I do exactly:

pinecone.init(api_key=key, environment=region)
index = pinecone.Index(<INDEX_NAME>)
delete_response = index.delete(namespace="96", filter={"file_pk": "16"})

# I have also tried this:
delete_response = index.delete(namespace="96", filter={"file_pk": {"$eq": "16"}})

When I make a query on namespace “96” I can see that file_pk exists:

{"content": "With anxious grap...",  "tokens": 202, "file_pk": "16"}

I can delete all records under a namespace with no problems but when I try with a filter nothing happens. The response from delete is {}.

Is this a bug or do I do something wrong? If it’s a bug, is there a workaround I could use until its fixed?

PS: I have also tried making a POST request to the API. Same results ({}).

Thanks in advance.

So does this make sense? Is this something that you guys are working on? Does it supposed to work like this?

Hi @Greg.C,

That’s the right way to delete by metadata. I just tried it myself and confirmed it works. In my case, I had a namespace called “example_namespace” and one of the vectors in it had a vector ID of “item_5”. I confirmed that vector had metadata setting “category: sports”, and delete with the filter worked.


>>> index.fetch(ids=["item_1"],namespace="example_namespace")
{'namespace': 'example_namespace',
 'vectors': {'item_1': {'id': 'item_1',
                        'metadata': {'category': 'music',
                                     'colors': ['purple', 'green', 'yellow'],
                                     'time_stamp': 0.1},
                        'values': <snip>
>>> index.delete(namespace='example_namespace',filter={"category":"music"})
{}
>>> index.fetch(ids=["item_1"],namespace="example_namespace")
{'namespace': 'example_namespace', 'vectors': {}}

Can you share the query you ran that returned that vector?