Native PostgreSQL vector similarity search through GraphQL. 9+ distance operators, HNSW indexing, semantic search.
FraiseQL exposes all pgvector distance operators through type-safe GraphQL filters. Dense and sparse vectors, custom distance functions, and vector aggregations.
| Operator | GraphQL Filter | Use Case | Range |
|---|---|---|---|
| Dense Vectors | |||
| <=> cosine_distance | cosineDistance | Text similarity, recommendations | 0.0 (identical) to 2.0 (opposite) |
| <-> l2_distance | l2Distance | Euclidean distance | 0.0+ (smaller = more similar) |
| <+> l1_distance | l1Distance | Manhattan distance | 0.0+ (smaller = more similar) |
| <#> inner_product | innerProduct | Negative inner product | -∞ to 0.0 (larger = more similar) |
| <~> hamming_distance | hammingDistance | Binary vectors | 0+ bits differ |
| <%> jaccard_distance | jaccardDistance | Set similarity | 0.0 (identical) to 1.0 (no overlap) |
| Sparse Vectors | |||
| sparse_cosine_distance | sparseCosineDistance | Sparse text embeddings | 0.0 to 2.0 |
| sparse_l2_distance | sparseL2Distance | Sparse Euclidean distance | 0.0+ |
| sparse_inner_product | sparseInnerProduct | Sparse inner product | -∞ to 0.0 |
Type-safe vector filtering with automatic PostgreSQL query generation. No SQL injection, full type safety.
input VectorFilter {
# Dense vector operators
cosineDistance: VectorDistanceFilter
l2Distance: VectorDistanceFilter
l1Distance: VectorDistanceFilter
innerProduct: VectorDistanceFilter
hammingDistance: VectorDistanceFilter
jaccardDistance: VectorDistanceFilter
# Sparse vector operators
sparseCosineDistance: VectorDistanceFilter
sparseL2Distance: VectorDistanceFilter
sparseInnerProduct: VectorDistanceFilter
# Additional functions
customDistance: CustomDistanceFilter
vectorNorm: VectorNormFilter
quantizedDistance: QuantizedDistanceFilter
}
input VectorDistanceFilter {
vector: [Float!]!
threshold: Float
limit: Int
}
Industry-standard ANN indexing for billion-scale vector search with 99.9% recall.
PostgreSQL's built-in IVF implementation for high-dimensional vector search.
Vector filtering passes through FraiseQL's Rust pipeline for sub-millisecond processing.
query SemanticSearch($embedding: [Float!]!) {
products(
filter: {
descriptionEmbedding: {
cosineDistance: {
vector: $embedding
threshold: 0.8
limit: 10
}
}
}
) {
id
name
description
similarity: _distance
}
}
SELECT
id, name, description,
1 - (embedding <=> $1) as _distance
FROM tb_product
WHERE embedding <=> $1 <= 0.8
ORDER BY embedding <=> $1
LIMIT 10;
Sentence transformers, CLIP embeddings, local inference
text-embedding-ada-002, GPT-4 integration patterns
Embed API, multilingual embeddings, custom models
Start with semantic search and RAG systems using PostgreSQL + GraphQL
Get Started with pgvector →