Build a vector search engine
Stage 3 of 5v1 · 419a40ec

Search exact neighbours

Scan the store, filter candidates, and return k stable neighbours.

The correctness baseline

Implement search by scanning every item. It receives vector, k, metric, and an optional filter. Keep items whose metadata contains every requested key-value pair using JSON equality.

Sort by ascending distance and then lexicographic id. Return at most k objects containing only id and distance. Reuse six-decimal rounding.

This O(n) search becomes the oracle for evaluating the approximate index: optimize only after establishing a correct baseline.

Acceptance criteria

  • k must be a positive integer.
  • Ties are deterministic.
  • Filter before sorting and limiting.