Skip to content

Support for ANN Query Planning with HNSW Indexes #3848

@hatyo

Description

@hatyo

Now that HNSW-backed vector indexes are implemented and functional, we should add native support for planning Approximate Nearest Neighbor (ANN) queries in SQL, here is an example for performing efficient K-nearest neighbor searches through SQL:

SELECT docId, title, euclidean_distance(embedding, CAST([1.0, 0.0, 0.0] AS VECTOR(3, HALF))) AS distance
FROM documents
WHERE zone = 'zone1' AND bookshelf = 'fiction'
  AND ROW_NUMBER() OVER (
      PARTITION BY zone, bookshelf
      ORDER BY euclidean_distance(embedding, CAST([1.0, 0.0, 0.0] AS VECTOR(3, HALF))) ASC
  ) <= 3

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestplannerRelated to the query plannerrelationalissues related to relational FDB

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions