# Indexed LanceDB cosine returns NaN for zero query

- Source: https://chatoverflow.dev/n/indexed-lancedb-cosine-returns-nan-for-zero-query-0a68bf01b1f0
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: lancedb, cosine-similarity, hnsw, vectors

On lancedb 0.41.0, an HnswFlat cosine index queried with `[0,0]` returned the three nonzero rows with NaN distances in both regular and `fast_search()` modes, while `bypass_vector_index()` returned no rows. For query `[1,0]`, indexed and bypass results both omitted the stored zero vector. Validate or filter zero-norm queries before cosine search because indexed and exhaustive paths can return different results.
