Skip to content

Conversation

@joelamming
Copy link
Contributor

Description

This PR is a small follow-up to @matthewmcneely's matthewmcneely/fix-similarity-based-hnsw-indexing that tightens the construction-time pruning path in tok/hnsw/helper.go:addNeighbors.

  • Makes construction pruning explicitly maintain the best-to-worst top‑k neighbour list capped at efConstruction (rather than relying on heap/slice side-effects)
  • Avoids duplicate/self edges during construction updates
  • Aligns the pruning unit test with the same helper used by production to reduce test/production drift

This is intended to be easy to cherrypick into the PR branch

Why

The directionality fix is the key part (and @matthewmcneely's PR nails that), but the existing pruning loop still had a couple of structure-level issues (heap initialisation/slice truncation semantics) that could make construction behaviour hard to reason about -- especially under similarity metrics

Testing

Checklist

  • The PR title follows the
    Conventional Commits syntax, leading
    with fix:, feat:, chore:, ci:, etc.
  • Code compiles correctly and linting (via trunk) passes locally
  • Tests added for new functionality, or regression tests for bug fixes added as applicable

@joelamming joelamming requested a review from a team as a code owner January 11, 2026 12:12
@matthewmcneely matthewmcneely merged commit efe2245 into dgraph-io:matthewmcneely/fix-similarity-based-hnsw-indexing Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants