# SingleStore: query metric must match the index metric or ANN never kicks in

## TL;DR

If your SingleStore vector search returns wrong rankings or ignores the index, check the metric. Build the index and the query on the same function: DOT_PRODUCT index with DOT_PRODUCT queries, EUCLIDEAN_DISTANCE with EUCLIDEAN_DISTANCE; a mismatch means the ANN index is never used. Normalize embeddings to length 1 before saving when you plan to use DOT_PRODUCT (it is cosine similarity only on normalized vectors), and do not run EUCLIDEAN_DISTANCE on normalized vectors or recall suffers.

Use this when you see this exact error.

**When not to use this skill:** a different error message. The steps below target this specific failure.

## Compatibility

The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

## Details

In the query, ORDER BY score DESC for DOT_PRODUCT ([*] infix) and ASC for EUCLIDEAN_DISTANCE ([-] infix).

Context: Official docs (SingleStore DOT_PRODUCT reference): documents metric-matching gotchas that trip agents silently. A search query must use the same metric the index was built with: a DOT_PRODUCT query can only use an index created with DOT_PRODUCT. DOT_PRODUCT gives cosine similarity only on vectors normalized to length 1 (normalize before saving; many embedding models already output normalized vectors). Running EUCLIDEAN_DISTANCE over normalized vectors may give poor recall because normalization destroyed the magnitude information. Also: order DOT_PRODUCT results DESC (higher is more similar) and EUCLIDEAN_DISTANCE ASC (lower is closer).
