Euclidean distance measures the straight-line distance between two points in vector space. In vector databases, it helps rank stored embeddings by how close they are to a query embedding, supporting semantically similar results. section 12.1.2 section 12.2.3
Use Euclidean distance when spatial separation between vectors is meaningful:
- Apply it to image-recognition and clustering tasks, where the distance between points carries practical significance. section 12.2.3
- Compare it with cosine similarity and dot product when choosing a vector-search similarity metric. section 12.2.3
- Use it as the distance metric guiding nearest-neighbor navigation in HNSW indexes. section 12.2
Embedding search workflow
An embedding model converts stored content and a user query into vectors. The vector database compares the query vector with stored vectors using a similarity measure such as Euclidean distance, then returns the closest results. section 12.1.2
Figure 12.2 Vector database operations. Data is processed by an embedding model, transforming it into vector embeddings such as [1.45, ..., 1.01, 0.89, 0.06]. These embeddings are stored in a vector database. Queries from the application are also transformed into embeddings before the database is searched. The most relevant results based on these query embeddings are then retrieved and returned as query results. (Image © MongoDB 2024 CC BY-NC-SA 3.0)
Trace how source data becomes embeddings, enters a vector database, and produces retrieved results for an embedded query. section 12.1.2







