JS/TS Client v3: nearVector with named vectors always returns same results (CLIP, multi-vector collection)

Hi,
I am using the JS/TS client v3 to search a collection with named vectors (text_vector and image_vector). I am using CLIP model for my embeddings, so both vectors are 768-dimensional and cross-modal search works as expected in the Weaviate console (GraphQL), where I get different results for different query vectors.

This is my code for Weaviate console:

# Powered by GraphiQL
{
  Get {
    FashionItem(
      limit: 5
      nearVector: {
        vector: embedding
        targetVectors: ["text_vector"]
      }
    ) {
      name
      description
      imageUrl
      url
      brandId
      price
      _additional {
        distance
      }
    }
  }
}

However, when I run the following code in TypeScript, I always get the same results, regardless of the input vector:

`const queryOptions = {
  limit: limit,
  offset: offset,
  returnProperties: [
    "name",
    "description",
    "imageUrl",
    "url",
    "brandId",
    "price",
  ],
  nearVector: {
    text_vector: embedding, //vector of 768 dimension 
  },
  targetVector: ["text_vector"],
};

result = await collection.query.fetchObjects(queryOptions);`

Is there something wrong with my query, or could this be a bug in the client? As I said before, the same search in the console works as expected, but in TypeScript the results do not change with different vectors.

Any help would be appreciated.

hi @MELINA_BELEN_JAUREGU !

You are using fetchObjects instead of nearVector.

This is what you will need:

result = await collection.query.nearVector(
  [1,2,3], 
  {
    returnProperties: [
      "name",
      "description",
      "imageUrl",
      "url",
      "brandId",
      "price",
    ],
    targetVector: ["text_vector"],
    limit: 5,
    offset: 10
  }
);

Check here our docs on nearVector: Vector similarity search | Weaviate Documentation

Let me know if this helps!

Happy coding!! :slight_smile:

Yes that was the problem. Thanks a lot!!

1 Like