feat: add diversity selection via MMR for hybrid and near* queries - #366
Merged
Conversation
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Secrets | View in Orca |
Summary - Weaviate C# Client CoverageSummary
CoverageWeaviate.Client - 49.5%
Weaviate.Client.Analyzers - 0%
Weaviate.Client.VectorData - 50.3%
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds MMR diversity selection to gRPC hybrid search across typed and untyped query/generate APIs.
Changes:
- Adds the
Diversity.MMRmodel and gRPC mapping. - Propagates diversity options through hybrid overloads.
- Adds unit and version-gated integration coverage.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
TypedQueryClient.Hybrid.cs |
Exposes MMR on typed queries. |
TypedGenerateClient.Hybrid.cs |
Exposes MMR on typed generation. |
QueryClient.Hybrid.cs |
Exposes MMR on query APIs. |
GenerateClient.Hybrid.cs |
Exposes MMR on generation APIs. |
Models/Search.cs |
Defines Diversity.MMR. |
gRPC/Search.cs |
Forwards selection to request building. |
gRPC/Search.Builders.cs |
Maps MMR fields to protobuf. |
PublicAPI.Unshipped.txt |
Tracks API additions and removals. |
TestHybridDiversitySyntax.cs |
Tests protobuf request mapping. |
TestSearchHybrid.cs |
Tests server-side MMR behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Diversity/MMR was wired into hybrid only. base_search.proto carries an optional Selection on NearVector, NearTextSearch, NearObject and each Near*Search message, and the server has supported it since 1.37.0 — hybrid diversity is the newer 1.38.6 addition, so the broader surface was in fact the older one. Threads diversitySelection through the 74 near* overloads across the query, generate and typed clients, and moves the hybrid mapping into a shared BuildSelection helper. No proto change was needed. Aggregate is deliberately excluded, matching the python client.
bevzzz
approved these changes
Aug 13, 2026
# Conflicts: # src/Weaviate.Client/PublicAPI.Unshipped.txt
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
g-despot
added a commit
to Shaurya2k06/csharp-client
that referenced
this pull request
Aug 14, 2026
PR weaviate#358 was written against weaviate#355 (feat/boost-query-api), so its <param> tags describe that branch's API rather than main's: - `boost` does not exist on main, so 30 `<param name="boost">` tags document a parameter that is not there (CS1572). They belong with weaviate#355, which is the PR that introduces the parameter. - `diversitySelection` was added to the same 30 methods by weaviate#366 after this PR was written, and was left undocumented (CS1573). Drop the boost tags and document diversitySelection instead, placing each tag at the position its parameter occupies in the signature (after `bm25Operator` in the Hybrid overloads, `distance` in GenerateClient.NearVector, `offset` in the QueryClient.NearText extensions). Also align two style details the PR introduced: `<param name="client">` reads "The client" (26 instances repo-wide, none of "The query client"), and the two QueryClient.NearText extension blocks take the trailing period their prose-style neighbours all use. The worklist was derived from the compiler, not by hand: `dotnet build --no-incremental` now reports 0 CS1572 and 0 CS1573, and the normalized warning set is byte-identical to origin/main (55 unique warnings on both).
g-despot
added a commit
that referenced
this pull request
Aug 14, 2026
Brings in #359 (module endpoint/location), #365 (BM25Operator.AndCross + searchOperator on generate.bm25), #366 (diversitySelection across hybrid and the near* family), and #367 (multimodal vectorizer weights). All of the .cs overload files auto-merged: boost is inserted after `rerank` and diversitySelection after `bm25Operator`/before `autoLimit`, so the two parameter additions never collided. Verified structurally in both directions (merged-minus-boost == origin/main, merged-minus-diversitySelection/ searchOperator == the branch) rather than trusting the auto-merge. The only textual conflict was PublicAPI.Unshipped.txt, where both sides emit a *REMOVED* line plus a replacement signature for the same 102 overloads. Resolved to a deduplicated union (102 identical *REMOVED* lines collapsed), then adjudicated by the public API analyzer: 204 single-parameter signatures were stale (RS0017) and 102 combined signatures were missing (RS0016). After applying those, the RS0016/RS0017 sets are identical to both parents'. Parameter counts after the merge match each parent exactly: boost 111 declarations (as on the branch), diversitySelection 105 and searchOperator 10 (as on main).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
Diversity.MMR(limit, balance)for hybrid and near* search (gRPC-only), on every query, generate and typed overload — 74 in total. Both fields are optional on the wire; the server requireslimit>= 1 and treats an omittedbalanceas 0.0 (pure diversity). Not exposed on aggregate, matching the Python client.Server floors differ by surface: near* diversity has been supported since 1.37.0, hybrid diversity since 1.38.6. No client-side version guard, matching Python — an older server ignores the unknown proto field rather than misinterpreting it, unlike the AndCross case in #365.
No proto change was needed:
base_search.protoalready carries an optionalSelectiononHybrid,NearVector,NearTextSearch,NearObjectand eachNear*Searchmessage.Integration tests gated
RequireVersion("1.38.6"), including result-ordering non-vacuity checks.Stacked on #365 — merge that first.