Skip to content
This repository was archived by the owner on May 26, 2026. It is now read-only.
This repository was archived by the owner on May 26, 2026. It is now read-only.

[Design] Search Embedded Aggregation #37

Description

@MrPresent-Han

Summary

Propose a design for Search Embedded Aggregation: extend Milvus vector search to return per-group top-K hits and per-group aggregation metrics (avg / sum / count / max / min) in a single request, aligning with Elasticsearch's terms + top_hits + metric sub-aggregation combo.

Motivation

Milvus today supports single-field group_by_field + group_size for grouping search results, but the most common vector-search analytics requests — e.g. "for each document, return the top-2 most similar chunks AND the average / max similarity / chunk count of that document" — cannot be expressed in a single search call. Users must issue two separate requests (search + query aggregation) and stitch results on the client, losing both ergonomics and latency.

Gap Analysis

# Capability ES Milvus master Gap
R1 Single-field grouping yes yes covered
R2 Per-group top-K hits yes (top_hits.size) yes (group_size) covered
R3 Multi-field flat grouping (ES multi_terms) yes segcore foundation only (commit 247d55bb36) Proxy / QueryNode / SDK
R4 Per-group metrics (avg/sum/count/max/min/...) yes (20+) no core gap
R5 Non-vector sort inside a group yes no uncovered
R6 Hierarchical (nested) grouping yes no uncovered

R4 is the dominant gap.

Scope

  • R3 — Multi-field flat grouping aligned with ES multi_terms (top segcore work already landed in commit 247d55bb36, Go layer still missing).
  • R4 — Leaf-level per-group metrics (count / sum / avg / max / min in Phase 1; cardinality / percentiles later).
  • R5 — Non-vector group-internal sort.
  • R6 — 2-level nested grouping via proxy-side flattening over composite keys, with group_count_safe_factor and metric_safe_factor knobs controlling two orthogonal approximation errors. Leaf-only metrics in Phase 1.

Design Document

A full MEP has been drafted: design_docs/20260413-search_embedded_agg.md (PR incoming).

Related Work

  • Commit 247d55bb36feat: support search embeded group by — segcore composite-key foundation already merged locally on branch support-embeded-groupby-master.

cc @MrPresent-Han

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions