Skip to content

feat: dotted nested-field groupBy for vector search (follow-up to #4067) #4072

Closed

Description

@lvca

Feature Request: Nested-Field groupBy (Dot Notation)

Follow-up to #4067, which shipped flat-property groupBy on vector.neighbors, vector.sparseNeighbors, and vector.fuse. This issue tracks support for nested-field paths like metadata.author or provenance.source.id.

Background

The MVP from #4067 looks up the grouping key with a flat record.get(groupBy) call. For schemas where the diversification field lives inside a nested map / embedded document, the user has to flatten the field manually before indexing.

Qdrant supports nested paths in group_by via dot notation (metadata.subfield), as does Milvus's group_by_field. ArcadeDB's MATCH / LET / SQL property access already supports dotted paths via Document.get(path) or via projection expressions, so the lookup primitive is available; what's missing is the path-aware reader inside the grouping helpers.

Design

Path resolution

Two equivalent options:

  1. Reuse Document.get(String) directly if it already handles dotted paths (verify against Document / MutableDocument / nested Map<String, Object> semantics). If yes, the change in SQLFunctionVectorNeighbors, SQLFunctionVectorSparseNeighbors, and SQLFunctionVectorFuse is purely the behavioural test plus a docstring update.
  2. Add an explicit dotted-path reader that splits on . and descends through Map / Document / EmbeddedDocument / List (with index syntax path[N] deferred to a follow-up). Mirror what the SQL projection executor does for metadata.author access.

Pick whichever matches the existing SQL-side dotted-path reader so the behaviour is consistent everywhere in the engine.

Type semantics

Nested paths can resolve to any property type. Document groupBy paths must resolve to a value that has a stable equals / hashCode:

  • STRING, INTEGER, LONG, BOOLEAN, FLOAT, DOUBLE, DATETIME types: fine.
  • MAP / EMBEDDED / LIST: rejected with a clear error at first lookup time. (Or auto-stringified, which is friendlier but more error-prone; pick stringification only if it matches the existing SQL behaviour.)
  • null: treated as its own group key (matches Qdrant).

Edge cases

  • Path that does not exist on a record: that record's group key is null, and the row joins the null group.
  • Path that resolves to an array: error or stringify (decide based on SQL precedent).
  • Mixed types across documents at the same path: group by Java equals / hashCode, which means 1 and 1.0 are in different groups. Document this.

Acceptance criteria

  • groupBy: 'metadata.author' (or any dotted path) works on vector.neighbors.
  • Same on vector.sparseNeighbors.
  • Same on vector.fuse (post-fusion grouping).
  • Behaviour matches the existing SQL projection / LET expression resolution for the same path.
  • Test: 100 docs across nested groups (metadata.author), groupBy='metadata.author' returns one row per author.
  • Test: documents with the path missing fall into the null group.
  • Test: backwards compatibility with flat property names.

Out of scope

  • List indexing in the path (provenance.sources[0].id).
  • Glob / wildcard paths.
  • Type coercion (e.g., normalize Integer 1 and Double 1.0 into the same group).

Related

  • Parent: #4067 (groupBy MVP, shipped)
  • Sibling follow-up: traversal-integrated groupBy
  • Discussion: #4044

Activity

  1. added
    enhancement
    on May 3, 2026
  2. added a commit that references this issue on May 3, 2026
  3. self-assigned this
    on May 4, 2026
  4. added theissue type on May 4, 2026
  5. added this to the 26.5.1 milestone on May 4, 2026
  6. lvca commented on May 4, 2026

    @lvca
    MemberAuthor

    Implemented in this PR via SQLFunctionVectorAbstract.readNestedField + SQLFunctionVectorNestedGroupByTest (5 tests)

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

Metadata

Metadata

Assignees

Labels

enhancementfeaturesql

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions