WeaviateQueryError when using JS/TS client to query named vectors - class has multiple vectors, but no target vectors were provided

Description

Hello, I’m using Weaviate Cloud for my RAG application and recently ran into this error after upgrading to version 1.26.7 that never occurred using earlier versions:

WeaviateQueryError: Query call with protocol gRPC failed with message: /weaviate.v1.Weaviate/Search UNKNOWN: extract target vectors: class <class_name> has multiple vectors, but no target vectors were provided
at /var/task/node_modules/weaviate-client/dist/node/cjs/grpc/searcher.js:43:19
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getKeywords (/var/task/index.js:58:26)
at async Promise.all (index 0)
at async exports.handler (/var/task/index.js:166:40)

My collection was created using:

collection = client.collections.create(
    name="<class_name>",
    properties=[
        wc.Property(name="text", data_type=wc.DataType.TEXT),
        wc.Property(name="keywords", data_type=wc.DataType.TEXT),
    ],
    vectorizer_config=[
        wc.Configure.NamedVectors.text2vec_openai(
            name="text", source_properties=["text"]
        ),
        wc.Configure.NamedVectors.text2vec_openai(
            name="keywords", source_properties=["keywords"]
        ),
    ],
    generative_config=wvc.config.Configure.Generative.openai()
)

After inserting documents, I can make queries without issue on the Python client using:

response = collection.generate.near_text(
    query=question,
    target_vector="keywords",
    limit=5,
    grouped_task = "<task_prompt>"
)

However, I’m using weaviate-client in Node.js and running into the error above now even though the query worked fine in earlier Weaviate versions. JS usage:

const response = await collection.generate.nearText(
    query, {
        groupedTask: `<task_prompt>`,
        limit: 5,
        targetVector: "keywords"
})

When I remove the target_vector keyword from the Python script, I run into a similar error:

AioRpcError: <AioRpcError of RPC that terminated with:
	status = StatusCode.UNKNOWN
	details = "extract target vectors: class UMMS has multiple vectors, but no target vectors were provided"
	debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"extract target vectors: class UMMS has multiple vectors, but no target vectors were provided", grpc_status:2, created_time:"2024-10-24T20:54:53.071755673+00:00"}"
>

I’m not sure how to fix this issue. I’ve upgraded weaviate-client to 3.1.5 and 3.2.0 and still running into this error. Any insight would be helpful, thank you.

Server Setup Information

  • Weaviate Server Version: 1.26.7
  • Deployment Method: Weaviate Cloud
  • Multi Node? Number of Running Nodes:
  • Client Language and Version: JavaScript v3.0.9, v3.1.5, v3.2.0
  • Multitenancy?:

Any additional Information

Hi @Kyle_Xiong, welcome to the community!

It looks to me like you are using the .generate.nearText function incorrectly. This is its type signature:

* @param {string | string[]} query - The query to search for.
  * @param {GenerateOptions<T>} generate - The available options for performing the generation.
  * @param {NearTextOptions<T>} [opts] - The available options for performing the near-text search.
  * @return {GenerateReturn<T>} - The results of the search including the generated data.
  */
nearText(
  query: string | string[],
  generate: GenerateOptions<T>,
  opts?: NearTextOptions<T>
): GenerateReturn<T>;

showing that it accepts at least two and at most three arguments. The second argument is a required object in which you supply your generative options with the third argument as an optional object in which you supply any of the parameters you would also in the query namespace methods.

So for your example, if you try the following then it will work:

const response = await collection.generate.nearText(query, {
  groupedTask: `<task_prompt>`,
}, {
  limit: 5,
  targetVector: "keywords"
})

Usually such an error with the API usage would be caught by the TS compiler. Do you perhaps have it disabled or are you working in JS?

Also, I do not understand why your provided query worked with older Weaviate versions but suddenly failer on a newer one. It could be that there was some implicit behaviour on the server that was being activated by the query you were sending that allowed it to succeed!

I hope this helps, if not then let me know!

Hi Tommy, thanks for the reply! You’re right, I was using the generate API incorrectly - I was using it analogously to query.nearText and didn’t see that the grouped_task keyword belongs in the 2nd object. Not sure why the API call worked in earlier versions either, but glad it’s fixed now. Thanks again!