---
title: "Delete objects"
description: "How to delete objects in Weaviate with code examples in Python, TypeScript, Go, Java, and C#."
url: https://docs.weaviate.io/weaviate/manage-objects/delete
---

# Delete objects

Weaviate allows object deletion by id or by a set of criteria.

**Additional information**

- To delete objects, you must provide the collection name as well as identifying criteria (e.g. object id or filters).
- For [multi-tenancy](https://docs.weaviate.io/weaviate/concepts/data#multi-tenancy) collections, you will also need to specify the tenant name when deleting objects. See [Manage data: multi-tenancy operations](https://docs.weaviate.io/weaviate/manage-collections/multi-tenancy) for details on how.

> [!WARNING]
>
> **Collection (class) Name in Object CRUD Operations**
>
> Collections act like namespaces, so two different collections could have duplicate IDs between them.
>
> Prior to Weaviate `v1.14` you can manipulate objects without specifying the collection name. This method is deprecated. It will be removed in Weaviate `v2.0.0`.
>
> Starting in `v1.20`, you can have [multi-tenant](https://docs.weaviate.io/weaviate/concepts/data#multi-tenancy) datasets. When `multi-tenancy` is enabled, the tenant name is required.
>
> Always include the collection name, and, when enabled, the tenant name.

## Delete object by id

To delete by id, specify the collection name and the object id.

**Python**

```py
uuid_to_delete = "..."  # replace with the id of the object you want to delete

collection = client.collections.use("EphemeralObject")
collection.data.delete_by_id(
    uuid_to_delete
)
```

**JavaScript/TypeScript**

```ts
await client.collections.delete('EphemeralObject')
await client.collections.create({ name: 'EphemeralObject'})
const myCollection = client.collections.use('EphemeralObject')

let idToDelete = '...';  // replace with the id of the object you want to delete
await myCollection.data.deleteById(idToDelete)
```

**Go (v5)**

```go
idToDelete := "..." // replace with the id of the object you want to delete

client.Data().Deleter().
  WithClassName("EphemeralObject").
  WithID(idToDelete).
  Do(ctx)
```

**Go (v6)**

```go
collection := client.Collections.Use("EphemeralObject")
id := uuid.MustParse("f1a2b3c4-d5e6-4f7a-8b9c-5d6e7f8a9b0c") // The object to delete.

err := collection.Data.Delete(ctx, id)
if err != nil {
  // handle error
  panic(err)
}
```

**Java**

```java
collection.data.deleteById(uuidToDelete);
```

**C#**

```csharp
await collection.Data.DeleteByID(uuidToDelete);
```

### Error handling

If the id does not exist, the status you get back depends on the collection's topology. A delete that lands on a single, unreplicated shard (replication factor `1`) returns `404 Not Found`. In a replicated collection, the same request can return a success status, so success is not proof that the object was there.

The clients surface this differently. The Python client's `delete_by_id()` returns `False` for the 404 and does not raise, while the TypeScript client's `deleteById()` rejects. If your code depends on knowing whether the object existed, [check that the object exists](https://docs.weaviate.io/weaviate/manage-objects/read#check-object-existence) first rather than reading the delete response.

## Delete multiple objects

To delete objects that match a set of criteria, specify the collection and a [`where` filter](https://docs.weaviate.io/weaviate/search/similarity).

**Python**

```py
from weaviate.classes.query import Filter

collection = client.collections.use("EphemeralObject")
collection.data.delete_many(
    where=Filter.by_property("name").like("EphemeralObject*")
)
```

**JavaScript/TypeScript**

```ts
await client.collections.delete('EphemeralObject')
await client.collections.create({ name: 'EphemeralObject'})
const myCollection = client.collections.use('EphemeralObject')

const response = await myCollection.data.deleteMany(
  myCollection.filter.byProperty('name').like('EphemeralObject*')
)

console.log(JSON.stringify(response))
```

**Go (v5)**

```go
response, err := client.Batch().ObjectsBatchDeleter().
  WithClassName("EphemeralObject").
  WithOutput("minimal").
  WithWhere(filters.Where().
  	WithPath([]string{"name"}).
  	WithOperator(filters.Like).
  	WithValueText("EphemeralObject*")).
  Do(ctx)
if err != nil {
  // handle error
  panic(err)
}

fmt.Printf("%+v\n", *response)
```

**Go (v6)**

```go
collection := client.Collections.Use("EphemeralObject")

_, err := collection.Data.DeleteSelected(ctx, data.DeleteSelected{
  Filter: &filter.Cond{
    Target:   "name",
    Operator: filter.Like,
    Value:    "EphemeralObject*",
  },
})
if err != nil {
  // handle error
  panic(err)
}
```

**Java**

```java
collection.data.deleteMany(
    Filter.property("name").like("EphemeralObject*")
);
```

**C#**

```csharp
await collection.Data.DeleteMany(
    Filter.Property("name").IsLike("EphemeralObject*")
);
```

**Additional information**

- There is a configurable [maximum limit (QUERY\_MAXIMUM\_RESULTS)](https://docs.weaviate.io/deploy/configuration/env-vars#general) on the number of objects that can be deleted in a single query (default 10,000). To delete more objects than the limit, re-run the query.

### ContainsAny / ContainsAll / ContainsNone

Use `ContainsAny` / `ContainsAll` / `ContainsNone` filters to delete of objects by a set of criteria.

**Python**

```py
from weaviate.classes.query import Filter

collection = client.collections.use("EphemeralObject")
collection.data.delete_many(
    where=Filter.by_property("name").contains_any(["europe", "asia"])
)
```

**JavaScript/TypeScript**

```ts
await client.collections.delete('EphemeralObject')
await client.collections.create({ name: 'EphemeralObject'})
const myCollection = client.collections.use('EphemeralObject')

await myCollection.data.deleteMany(
  myCollection.filter.byProperty('name').containsAny(['europe', 'asia'])
)
```

**Go (v5)**

```go
  response, err := client.Batch().ObjectsBatchDeleter().
    WithClassName("EphemeralObject").
    WithOutput("minimal").
    WithWhere(filters.Where().
      WithPath([]string{"name"}).
      WithOperator(filters.ContainsAny).
      WithValueText("asia", "europe")).  // Note the array syntax
    Do(ctx)
```

**Go (v6)**

```go
collection := client.Collections.Use("EphemeralObject")

_, err := collection.Data.DeleteSelected(ctx, data.DeleteSelected{
  Filter: &filter.Cond{
    Target: "name",
    Operator: filter.ContainsAny, // Or filter.ContainsAll, filter.ContainsNone
    Value:    []string{"europe", "asia"},
  },
})
if err != nil {
  // handle error
  panic(err)
}
```

**Java**

```java
CollectionHandle<Map<String, Object>> collection =
    client.collections.use(COLLECTION_NAME);
collection.data.insertMany(Map.of("name", "asia"),
    Map.of("name", "europe"));

collection.data.deleteMany(
    Filter.property("name").containsAny("europe", "asia")
);
```

**C#**

```csharp
var collection = client.Collections.Use(COLLECTION_NAME);
await collection.Data.InsertMany(new[] { new { name = "asia" }, new { name = "europe" } });

await collection.Data.DeleteMany(
    Filter.Property("name").ContainsAny(["europe", "asia"])
);
```

## Delete multiple objects by id

To delete multiple objects by their id values, use a filter (e.g. `ContainsAny`) with `id` based criteria.

**Limitations**

There is an upper limit (`QUERY_MAXIMUM_RESULTS`) to how many objects can be deleted using a single query. This protects against unexpected memory surges and very-long-running requests which would be prone to client-side timeouts or network interruptions.

Objects are deleted in the same order that they would be fetched, by order of UUID. To delete more objects than the limit, run the same query multiple times until no objects are matched anymore.

The default `QUERY_MAXIMUM_RESULTS` value is 10,000. This may be configurable, e.g. in [the environment variables](https://docs.weaviate.io/deploy/configuration/env-vars).

**Python**

```py
from weaviate.classes.query import Filter

collection = client.collections.use("EphemeralObject")

response = collection.query.fetch_objects(limit=3)  # Fetch 3 object IDs
ids = [o.uuid for o in response.objects]  # These can be lists of strings, or `UUID` objects

collection.data.delete_many(
    where=Filter.by_id().contains_any(ids)  # Delete the 3 objects
)
```

**JavaScript/TypeScript**

```ts
await client.collections.delete('EphemeralObject')
await client.collections.create({ name: 'EphemeralObject'})
const myCollection = client.collections.use('EphemeralObject')

const response = await myCollection.query.fetchObjects({limit: 3})

const idList = response.objects.map(o => String(o.uuid))

await myCollection.data.deleteMany(
  myCollection.filter.byId().containsAny(idList)
)
```

**Go (v5)**

```go
  response, err := client.Batch().ObjectsBatchDeleter().
    WithClassName("EphemeralObject").
    WithOutput("minimal").
    WithWhere(filters.Where().
      WithPath([]string{"id"}).
      WithOperator(filters.ContainsAny).
      WithValueText("12c88739-7a4e-49fd-bf53-d6a829ba0261", "3022b8be-a6dd-4ef4-b213-821f65cee53b", "30de68c1-dd53-4bed-86ea-915f34faea63")).  // Note the array syntax
    Do(ctx)
```

**Go (v6)**

```go
collection := client.Collections.Use("EphemeralObject")

response, err := collection.Query.OverAll(ctx, query.OverAll{Limit: 3}) // Fetch 3 object ids
if err != nil {
  // handle error
  panic(err)
}
ids := make([]uuid.UUID, 0, len(response.Objects))
for _, obj := range response.Objects {
  ids = append(ids, obj.UUID)
}

_, err = collection.Data.DeleteSelected(ctx, data.DeleteSelected{
  Filter: &filter.Cond{
    Target:   filter.UUID,
    Operator: filter.ContainsAny,
    Value:    ids, // Delete the 3 objects
  },
})
if err != nil {
  // handle error
  panic(err)
}
```

**Java**

```java
QueryResponse<Map<String, Object>> queryResponse =
    collection.query.fetchObjects(q -> q.limit(3));
List<String> ids = queryResponse.objects()
    .stream()
    .map(WeaviateObject::uuid)
    .collect(Collectors.toList());

collection.data.deleteMany(
    Filter.uuid().containsAny(ids.toArray(new String[0])) // Delete the 3 objects
);
```

**C#**

```csharp
var queryResponse = await collection.Query.FetchObjects(limit: 3);
var ids = queryResponse.Objects.Select(obj => obj.UUID.Value).ToList();

await collection.Data.DeleteMany(
    Filter.UUID.ContainsAny(ids) // Delete the 3 objects
);
```

## Delete all objects

Objects must belong to a collection in Weaviate. Accordingly [deleting collections](https://docs.weaviate.io/weaviate/manage-collections/collection-operations#delete-a-collection) will remove all objects within them.

## Delete objects with Time-To-Live (TTL)

You can configure automatic deletion of objects after a specified time period using Time-To-Live (TTL) settings at the collection level. Read how to [set it up](https://docs.weaviate.io/weaviate/manage-collections/time-to-live) or learn more [about it](https://docs.weaviate.io/weaviate/concepts/data#time-to-live-ttl).

## Optional parameters

- You can use `dryRun` to check how many objects would be deleted, without actually performing the deletion.
- Set `output` to `'verbose'` to see more details (ID and deletion status) for each deletion.

**Python**

```py
from weaviate.classes.query import Filter

collection = client.collections.use("EphemeralObject")
result = collection.data.delete_many(
    where=Filter.by_property("name").like("EphemeralObject*"),
    dry_run=True,
    verbose=True
)

print(result)
```

**JavaScript/TypeScript**

```ts
await client.collections.delete('EphemeralObject')
await client.collections.create({ name: 'EphemeralObject'})
const myCollection = client.collections.use('EphemeralObject')

const response = await myCollection.data.deleteMany(
  myCollection.filter.byProperty('name').like('EphemeralObject'),
  {
    dryRun: true,
    verbose: true
  }
)

console.log(response);
```

**Go (v5)**

```go
response, err := client.Batch().ObjectsBatchDeleter().
  WithClassName("EphemeralObject").
  // Same `where` filter as in the GraphQL API
  WithWhere(filters.Where().
  	WithPath([]string{"name"}).
  	WithOperator(filters.Like).
  	WithValueText("EphemeralObject*")).
  WithDryRun(true).
  WithOutput("verbose").
  Do(ctx)
if err != nil {
  // handle error
  panic(err)
}

fmt.Printf("%+v\n", *response)
```

**Go (v6)**

```go
collection := client.Collections.Use("EphemeralObject")

res, err := collection.Data.DeleteSelected(ctx, data.DeleteSelected{
  Filter: &filter.Cond{
    Target:   "name",
    Operator: filter.Like,
    Value:    "EphemeralObject*",
  },
  DryRun: true,
})
if err != nil {
  // handle error
  panic(err)
}

fmt.Printf("Matched %d objects, deleted none\n", res.Matches)
```

**Java**

```java
var result = collection.data.deleteMany(
    Filter.property("name").like("EphemeralObject*"),
    c -> c.dryRun(true).verbose(true)
);

System.out.println(result);
```

**C#**

```csharp
var result = await collection.Data.DeleteMany(
    Filter.Property("name").IsLike("EphemeralObject*"),
    dryRun: true
);

Console.WriteLine(JsonSerializer.Serialize(result));
```

**Example response**

It should produce a response like the one below:

```json
{
  "dryRun": true,
  "match": {
    "class": "EphemeralObject",
    "where": {
      "operands": null,
      "operator": "Like",
      "path": [
        "name"
      ],
      "valueText": "EphemeralObject*"
    }
  },
  "output": "verbose",
  "results": {
    "failed": 0,
    "limit": 10000,
    "matches": 5,
    "objects": [
      {
        "id": "208cf21f-f824-40f1-95cb-f923bc840ca6",
        "status": "DRYRUN"
      },
      {
        "id": "8b2dddd4-2dc7-422c-885d-f9d5ff4e80c8",
        "status": "DRYRUN"
      },
      {
        "id": "49b3b2b4-3a77-48cd-8e39-27e83c811fcc",
        "status": "DRYRUN"
      },
      {
        "id": "847b31d0-dab4-4c1c-8cd3-af07c9d3dc2c",
        "status": "DRYRUN"
      },
      {
        "id": "147d9cea-5f9c-40c1-884a-f99bc8e9bf06",
        "status": "DRYRUN"
      }
    ],
    "successful": 0
  }
}
```

## Related pages

- [Connect to Weaviate](https://docs.weaviate.io/weaviate/connections)

- [References: REST - /v1/objects](https://docs.weaviate.io/weaviate/api/rest#tag/objects)
