0

I would like to delete records by query. The documentation does not mention this. I woudl like to do similar to:

where_filter = {
    "path": ["hash"],
    "operator": "Equal",
    "valueText": hash,
}

return (
    client.query
        .get("Collection", ["question", "answer", 'file', 'hash'])
        .with_where(where_filter)
        .do()
)

but instead of querying I would like to delete the records.

Is it event possible in Weaviate. Could not find an answer in the internet.

Yevhen Kuzmovych
  • 10,940
  • 7
  • 28
  • 48
RKO
  • 120
  • 9

1 Answers1

0

Yes, it is possible. Look at the docs for batch delete. For example:

import weaviate

client = weaviate.Client("http://localhost:8080")

# Optionally set the consistency level
client.batch.consistency_level = weaviate.data.replication.ConsistencyLevel.ALL  # default QUORUM
result = client.batch.delete_objects(
  class_name="Author",
  # same where operator as in the GraphQL API
  where={
    "operator": "Equal",
    "path": ["name"],
    "valueText": "Jane"
  },
  output="verbose",
  dry_run=False
)

print(result)
hsm207
  • 471
  • 2
  • 4