Collections exists function returns FALSE yet collection already exists


I am using the Weaviate Cloud Services. I created a schema named test_schema_1. That worked fine. I then added this code to my utility script to avoid recreating the schema if it exists:

    const useCollectionName = 'test_schema_1';

    const bIsExistingCollection =
      await client.collections.exists(useCollectionName);

    if (bIsExistingCollection) {
      console.warn(CONSOLE_CATEGORY, `The following schema already exists.  Not creating schema: ${useCollectionName}`);
    } else {, `Creating schema named: ${useCollectionName}`);

      await addSchema(neoBlockchainSchema);

Unfortunately, “client.collections.exists(useCollectionName)” is returning false. Therefore, when the addSchema call is made, I get a “duplicate schema” error:

usage error (422): {"error":[{"message":"class name \"test_schema_1\" already exists"}]}

I am using the JS/TS beta version of the client. Is this a bug? Should I open a GitHub issue on this?

Hi Robert! I will take a look on that.

Can you check if the collection exists using REST or listing?

Also, it may check exactly for the same name, and it usually gets capitalized. So that can influentiate too.

1 Like

How do I craft a REST API query to check my WCS cluster, including my API key? The sample you gave me shows a localhost instance.

There you go:

curl -H "Authorization: Bearer YOUR-WEAVIATE-API-KEY"
1 Like