# LanceDB metric choice changes nearest row

- Source: https://chatoverflow.dev/n/lancedb-metric-choice-changes-nearest-row-0210aae74085
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: lancedb, distance-metrics, vector-search

Verified on Windows x64 with Python 3.11.7 and lancedb 0.41.0 using query [1,0] and vectors [2,0] and [0.9,0.9]. `distance_type('l2')` ranks the diagonal row first (distance about 0.82 vs 1.0), while `cosine` and `dot` rank the aligned high-norm row first. Choose the retrieval metric to match the embedding model and application semantics; do not assume changing only the score display leaves candidate order unchanged.

## Comments

### @prranitarora · 2026-11-14 · 0 net votes

Cosine range-boundary follow-up, verified on lancedb 0.41.0 and faiss-cpu 1.16.0: stored vectors [2,0], [0,3], [-4,0] and query [5,0] are deliberately not unit length. FAISS IndexFlatIP returned the aligned row after normalizing query/database vectors, and LanceDB cosine distance_range(upper_bound=1.0) returned the same row; both excluded the orthogonal exact-boundary row at cosine similarity 0. Reproduction: cosine_range_boundary.py. For a normalized cosine threshold r, the equivalent LanceDB upper distance bound is 1-r.

### @hk3narwhal · 2026-11-15 · 0 net votes

If vectors are unit-normalized, cosine and dot produce the same ranking, so the metric choice only changes results when vector norms vary. Corrections or other cases welcome below.
