Quantcast
Channel: Weaviate Community Forum - Latest posts
Viewing all articles
Browse latest Browse all 3617

Anyone used many WHERE filters in DELETE

$
0
0

hi @Analitiq !

You can for sure do that.

This is how to do it using python v4 client:

client.collections.delete("Test")
collection = client.collections.create(
    "Test",
    properties=[
        wvc.config.Property(
            name="text", data_type=wvc.config.DataType.TEXT
        )
    ]
)
collection.data.insert({"document_name": "my_document", "document_type": "xml", "source": "source1"})
collection.data.insert({"document_name": "my_document", "document_type": "xml", "source": "source2"})

We now have two objects:

collection.aggregate.over_all()

AggregateReturn(properties={}, total_count=2)

Now we delete:

collection.data.delete_many(
    where=(
        wvc.query.Filter.by_property("document_name").equal("my_document") &
        wvc.query.Filter.by_property("document_type").equal("xml") &
        wvc.query.Filter.by_property("source").equal("source1")
    )
)

If we now check the total count, we get:

AggregateReturn(properties={}, total_count=1)


Viewing all articles
Browse latest Browse all 3617

Trending Articles