Skip to content

v6: Aggregate NearVector and OverAll#350

Open
bevzzz wants to merge 39 commits intov6from
v6-aggregate
Open

v6: Aggregate NearVector and OverAll#350
bevzzz wants to merge 39 commits intov6from
v6-aggregate

Conversation

@bevzzz
Copy link
Collaborator

@bevzzz bevzzz commented Mar 13, 2026

Merge #346 first to reduce diff

This PR adds the Aggregate namespace to the collection handle with 2 aggregation types: over all and near vector. I decided to add both at once to explore the differences in the API (one has a search filter, the other one doesn't) and see where their APIs have touching points.

As usual, a large part of the diff is dedicated to tests. Since NearVector and OverAll share the same underlying implementation (see aggregate.aggregate function), the tests focus on the OverAll query and only verify that NearVector parameter is set if Aggregate.NearVector() is called.

The syntax is something like this:

songs := c.Collections.Use("Songs")
overAll := aggregate.OverAll{
  TotalCount: true,
  Boolean: aggregate.Boolean{{ Property: "isSingle", PercentageTrue: true }},
}
songs.Aggregate.OverAll(ctx, overAll)

songs.Aggregate.OverAll.GroupBy(ctx, overAll, aggregate.GroupBy{
  Property: "album",
  Limit: 5,
})

// And for NearVector (Hybrid, BM25, etc)
songs.Aggregate.NearVector(ctx, aggregate.NearVector{
  Boolean: aggregate.Boolean{{ Property: "isSingle", PercentageTrue: true }},
  Query: query.NearVector{
    Target: types.Vector{Single: []float32{...}},
    Similarity: query.Distance(0.45),
  },
})

Introduce collections.Handle with Data and Query namespaces
MockTransport can now be created with stubs that describe
different request-response pairs by parameterizing them
with [any, any].

The Do method relies on reflection for detecting such cases
and treats them differently both when comparing the request
values and assigning responses back to dest.
- NewClient
- NewLocal
- NewWeaviateCloud
Copy link

@orca-security-eu orca-security-eu bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant