Delete object with id array failed

I am using weaviate typescript v3:

I have below test code:

const itemsIdToDelete = [
  'c0381cd9-4f9e-4d48-b0e9-33d0e8c3ffa7',
  'd0fe3dff-3135-4379-92b4-22229db68653'
]
deleteResult = await myCollection.data.deleteMany(
                  myCollection.filter.byId().containsAny(itemsIdToDelete),
                  {
                    dryRun: true,
                  }
                );

I got below output:

INFO    deleteResult {
  took: 0.0004886100068688393,
  failed: 0,
  matches: 0,
  successful: 0,
  objects: undefined
}

I have double check that the object with above id exist in the weaviate collection, screenshot of them:

Hi @alisha_liu,

That is super strange, I’ve just run a test on a dummy collection.

First I printed 3 UUIDs:

const myCollection = client.collections.get('Animals');
const res = await myCollection.query.fetchObjects({limit: 3})

for (const item of res.objects) {
    console.log(item.uuid)
}

Then, I took these 3 UUIDs to run the following delete command:

const itemsIdToDelete = [
    "327e9b13-3ca8-4fdf-867d-5f8326160bc8",
    "4452c466-8e38-421a-b4e6-5ccada98cdf6",
    "548ccd40-acef-4cf2-99d2-afda5e665399",
]

const deleteResult = await myCollection.data.deleteMany(
    myCollection.filter.byId().containsAny(itemsIdToDelete),
    {
        dryRun: true,
    }
);

Which gave me the following response - indicating that it would have deleted 3 objects:

{
  "took": 0.0006591000128537416,
  "failed": 0,
  "matches": 3,
  "successful": 3
}

Versions

Can you share the version of your weaviate-client and the weaviate version?

You can check your weaviate version by running:

console.log((await client.getMeta()).version)

Check object count

Sometimes, it is easy to misspell collection name.
Can you check that myCollection contains data, like this:

    const myCollection = client.collections.get('Animals');
    const overAll = await myCollection.aggregate.overAll()
    console.log(`Object Count: ${overAll.totalCount}`)

Dynamicaly grab uuids

Can you run the following script, which dynamically grabs 3 UUIDs and then maps them to an array of IDs.

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

const itemsIdToDelete = res.objects.map(o => o.uuid)
console.log(`UUIDs to delete:\n${JSON.stringify(itemsIdToDelete, null, 2)}`)

const deleteResult = await myCollection.data.deleteMany(
    myCollection.filter.byId().containsAny(itemsIdToDelete),
    {
        dryRun: true,
    }
);

console.log(JSON.stringify(deleteResult, null, 2))

Hi @sebawita ,

Thank you so much for help me debug the issues.

My project environment: node.js (version 22.0.0) typescript (version 5.3.3)

1 After run this command:console.log((await client.getMeta()).version),
I got this output: 1.26.0-rc.0

2 weaviate-client 3.1.4

Below is the script you provided and output:

  const result = await myCollection.aggregate.overAll();
  const totalCount = result.totalCount;
  console.log('totalCount',totalCount);
  const res = await myCollection.query.fetchObjects({ limit: 3 });

  const itemsIdToDelete = res.objects.map((o) => o.uuid);
  console.log(
    `UUIDs to delete:\n${JSON.stringify(itemsIdToDelete, null, 2)}`
  );

  const testdeleteResult = await myCollection.data.deleteMany(
    myCollection.filter.byId().containsAny(itemsIdToDelete),
    {
      dryRun: true,
    }
  );

  console.log("testdeleteResult",JSON.stringify(testdeleteResult, null, 2));

Output:

INFO totalCount 40
2024-12-17T13:56:47.332Z bc863d5c-78ed-426c-8b25-7e68b2d28e4a INFO UUIDs to delete:
[
“016d2780-44d3-409b-8047-d4bddd706705”,
“0fe66df1-a04e-439c-bcf8-addeabdaef4c”,
“1006e63e-d1db-402d-9e49-5150eac5339b”
]
2024-12-17T13:56:47.354Z bc863d5c-78ed-426c-8b25-7e68b2d28e4a INFO testdeleteResult {
“took”: 0.0007071029976941645,
“failed”: 0,
“matches”: 0,
“successful”: 0
}

My second test steps and result:
1Update my weaviate client from 1.26.0-rc.0 to 1.27.1
2 Update weaviate-client from 3.1.4 to 3.2.5
3 execute above function with same collection second time and get same result as above.

Addition information:
If I change collection, and run above code then got the result as expected.

Seems like the data exist in the problem collection are bad data, but after loading them via Postman, I can not figure out what’s the different with the worked data.