Group by using hybrid search - JS Client

Description

I’m trying to run a hybrid aggregate query that groups results by a tags property (an array) so I can get aggregates per tag. I’m passing a named vector (via targetVector) but the query fails with an error that looks like the named vector is empty.

What I expect
Group aggregated results by each tag while using hybrid search (named vector + alpha).

Code (JS client v3.8.x)

const results = await Article.aggregate.groupBy.hybrid(q, {
  groupBy: { property: 'tags' },
  vector: embedding,
  objectLimit: 250,
  targetVector: 'embedding_text_vector',   // named vector defined on the class
  alpha: 0.8
});

Actual error

WeaviateQueryError: Query call with protocol gRPC failed with message: /weaviate.v1.Weaviate/Aggregate UNKNOWN: aggregate: shard Nh4bhyq0ZBX0: no vector index for target vector “”

The error suggests the target vector name is empty (i.e. "") even though I passed targetVector: 'embedding_text_vector'.

Server Setup Information

  • Weaviate Server Version: 1.31
  • Deployment Method: Local
  • Multi Node? Number of Running Nodes: 1
  • Client Language and Version: JS Client, 3.8.1
  • Multitenancy?: No

Additional context / notes

  • The Article class has a tags property (array) and a named vector property embedding_text_vector (indexed).

  • I’m using a hybrid aggregate groupBy call (not a simple graphql query); my aim is to get aggregated results grouped by each tag while leveraging hybrid scoring (alpha + named target vector).

Question / help needed

  • Is targetVector supported by aggregate.groupBy.hybrid() for named vectors?

  • Could this be a client-side usage bug, or am I missing a server/schema configuration step (e.g., enabling the named vector index on the class/property)?

  • Any suggestions for debugging steps to confirm whether the named vector index exists and is accessible to the aggregate call?

Thanks in advance — happy to share the class schema or additional logs if that helps.

Hey @pawwi

The root cause is that the JS client (v3.8.x) doesn’t pass targetVector to aggregate.groupBy.hybrid(), so Weaviate gets an empty string and throws the “no vector index” error. Your named vector is fine it’s just a client-side gap.

What you can do right now:

  • If the default vector is okay, drop targetVector and the call will work.

  • If you need your named vector, switch to a raw GraphQL aggregate query for the moment; GraphQL does forward targetVector.

Quick check that your vector exists:

curl -s http://localhost:8080/v1/schema | jq '.classes[] | select(.class=="Article") .vectorConfig'

Look for "embedding_text_vector" in the output.

I couldn’t find an open ticket for this in weaviate/weaviate-ts-client, so it’s probably worth filing one. @DudaNogueira could you confirm this is a missing feature? If so, I’m happy to open the issue so it can get picked up in the next 3.8.x patch.

Hi there my friends!!

I was setting up a reproducible code in python, and I think there is something here :grimacing:

I was able to group by a text array while performing a near text, but not with a hybrid.

here is a MRE (minimum reproducible example)

Client: 4.16.9, Server: 1.32.7

import weaviate, os
from weaviate import classes as wvc

headers = {
    "X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY"),
}
client = weaviate.connect_to_local(
    headers=headers,
)
print(f"Client: {weaviate.__version__}, Server: {client.get_meta().get('version')}")

client.collections.delete("Test")
collection = client.collections.create(
    "Test",
    vector_config=[
        wvc.config.Configure.Vectors.text2vec_openai(
            name="my_named_vector",
            source_properties=["title"],
        )
    ]
)
collection.data.insert({"title": "a dog can bark loud", "tags": ["t1", "t2", "t3"], "tag": "tag1"})
collection.data.insert({"title": "a cat cannot bark", "tags": ["t2", "t3", "t4"], "tag": "tag2"})
collection.data.insert({"title": "The lion is the king of the forest", "tags": ["t3", "t4", "t5"], "tag": "tag3"})
collection.data.insert({"title": "Something about giraffes", "tags": ["t5"], "tag": "tag4"})

# near text can aggregate with a text array
# results = collection.query.near_text(
# hybrid cannot
results = collection.query.hybrid(
    #include_vector=True,
    query="bark forest",
    group_by=wvc.query.GroupBy(prop="tags", objects_per_group=10, number_of_groups=10),
    target_vector="my_named_vector",
    limit=50,
)
#print("results", results)
for group_name, group in results.groups.items():
    print(f"### {group_name}")
    for o in group.objects:
        print(f" - {o.properties.get('title')}")

this is the output I get for the near text query:

### t1
 - a dog can bark loud
### t2
 - a dog can bark loud
 - a cat cannot bark
### t3
 - a dog can bark loud
 - a cat cannot bark
 - The lion is the king of the forest
### t4
 - a cat cannot bark
 - The lion is the king of the forest
### t5
 - The lion is the king of the forest
 - Something about giraffes

I have poked around internally, and will update it here, as we may be facing two different issues here.

grouping by a tag property worked as expected.

Thanks!!

Thanks a ton for spinning up the MRE! :rocket:

Your Python run matches exactly what I was seeing on JS:

:white_check_mark: groupBy works fine with nearText

:cross_mark: The moment we switch to hybrid, grouping breaks even with a valid targetVector

That ties back to the earlier gRPC error (no vector index for target vector “”) I hit on the JS client. So looks like it’s not just a client quirk the server doesn’t fully handle groupBy + hybrid together yet.

I’ll go ahead and open a GitHub issue in the main weaviate/weaviate repo and include:

groupBy passes with nearText but fails with hybrid (tested on 1.32.7)

Your Python repro snippet

Confirmation that it breaks on both JS (3.8.x) and Python (4.16.9), which points to a server-side gap

Once the ticket’s up I’ll drop the link here so we can track it together. Really appreciate you testing this so quickly

1 Like

Awesome!!!

Thanks for your contributions!!

After an initial analysis from our core team, it indeed points to a bug :grinning_face:
and yes, we love finding new :bug:

:smiling_face_with_sunglasses:

Hey! We have a WIP PR

Thanks @Chaitanya_Kulthe and @DudaNogueira for digging into this so quickly! :folded_hands:

That clears things up for me, it’s good to know the issue isn’t with my schema or client usage, but rather that groupBy + hybrid isn’t fully supported yet. I’ll keep an eye on the linked PR and test again once it lands in a release.

In the meantime, I’ll fall back to nearText or GraphQL aggregate queries for grouping. Really appreciate the MREs and confirmation across both JS and Python clients, makes it much easier to follow along.

Looking forward to the fix!

2 Likes