[Question] Query weaviate

We are doing a POC only locally at first. But I cannot get this to work for the life of me :

const searchResponse = await weaviateClient.query(query);

        const documents = searchResponse?.data?.Get?.Document;
        if (!documents || documents.length === 0) {
            res.status(404).json({ error: 'No relevant documents found in Weaviate' });
            return; // 👈 Explicit return
        }

I get error that query does not exist on weaviate client.

This is my import code also :

import weaviate from ‘weaviate-client’;

Please help

Hey Johann :hugs:

I think there might be several things mixing up here.
First issue could be, that you are using query on the client but in all the examples I have seen it is being used on the collection.
So I assume something like the following probably works better :

const collection = client.collections.get(‘MyCoolCollectionName’);
const searchRespose=await collection.query(query);

I looked this up here: Search patterns and basics | Weaviate or Migrate from v2 to v3 | Weaviate

also it kind of looks like there is some mixing syntax of our old v2 TypeScript client with the v3 TypeScript client.
It looks like import weaviate from ‘weaviate-client' is using the new v3 package, whereas the way you are viewing the existing object is rather the old syntax. (SearchResponse?.data?…. )
You can inspect the returned object like this: Migrate from v2 to v3 | Weaviate
Where response.objects[0].properties will return the first object’s properties.

I hope this helps you :green_heart: