I want to delete a file from my database. I put every file in smaller chunks without id i think. (cannot find the id). I thought i could deleted every chunk if a word is in it. But i dont know what i did wrong

The error

File “C:\Python\Python311\Lib\site-packages\weaviate\batch\crud_batch.py”, line 1368, in delete_objects
res = _decode_json_response_dict(response, “Delete in batch”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Python\Python311\Lib\site-packages\weaviate\util.py”, line 798, in _decode_json_response_dict
raise UnexpectedStatusCodeException(location, response)
weaviate.exceptions.UnexpectedStatusCodeException: Delete in batch! Unexpected status code: 422, with response body: {‘error’: [{‘message’: “validate: invalid where filter: no such prop with name ‘filename’ found in class ‘Test’ in the schema. Check your schema files for which properties in this class are available”}]}.

the code:

import weaviate

client = weaviate.Client(
url = “http://10.0.128.34:8888”, # Replace with your endpoint
)

client.batch.delete_objects(
class_name=“Test”,
where={
“path”: [“filename”],
“operator”: “Like”,
“valueText”: “*JochemW.pdf”
},
)

my code

hi @jochem !!

Not sure I understood :thinking:

You find the object doing this search, but when you delete, it doesn’t get deleted?

Also, what is the version and deployment type.

Thanks!

hi @DudaNogueira,

I want to deleted some chunks out of my database. They all have one word in common. I want to deleted that kind of chunks. I dont have the object id of them so i want it to do it with a word. Is that possible?

Sure!

this is how, using python v4 latest client:

Just like you can search:

collection.query.fetch_objects(
    filters=Filter.by_property("text").contains_any(["car"])
).objects

you can also delete:

collection.data.delete_many(
    where=Filter.by_property("text").contains_any(["car"])
)

Let me know if this helps :slight_smile:

Hii @DudaNogueira,

first i didnt tell you, but I have python client V3. My weaviate database version is 3.26.2.
I also checked on weaviate the delete objects website. But i tried the delete multiple objects and the containsany.

Hi! Latest database version is 1.25.5.

3.26.2 is probably the client version :slight_smile:

Can you check the server version?

We strongly recommend using pyv4 as it will leverage GRPC and deliver way more performance on reads and writes.

Were you able to use with pyv3 client?

Thanks!

Hi @DudaNogueira,

py4 is not a option in this project. my database version is actually 1.24.1.

Were you able to use with pyv3 client?

no.

hi @jochem !

You will need to figure out the name of the property. You are passing filename which doesn’t exist.

you can check the properties of your collections with:

import weaviate
clientv3 = weaviate.Client("http://localhost:8080")
for item in clientv3.schema.get().get("classes"):
    print(item["class"], [p["name"] for p in item["properties"]])

make sure the filename field is in the collection you are querying.

Thanks!

Thank you i knew filename was wrong only i didnt knew what was right. It is something of your properties name there.

1 Like