surrealdb/agent-skills

surrealdb-vector

Vector search with SurrealDB using HNSW indexes, KNN queries, and similarity scoring.

First seen Apr 10, 2026

Installation

$ npx skills add surrealdb/agent-skills --skill surrealdb-vector

Summary

  • Vector search with SurrealDB using HNSW indexes, KNN queries, and similarity scoring.
  • Use when creating vector indexes, querying vectors with KNN distance operators, building semantic search or RAG pipelines, tuning HNSW parameters (EFC, M, M0, distance function, type), or implementing recommendation systems with SurrealDB.
  • Triggers: HNSW, vector, embedding, KNN, cosine, euclidean, semantic search, RAG, vector::distance.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from surrealdb/agent-skills.

npx skills add surrealdb/agent-skills

Browse all from surrealdb/agent-skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 25
License LICENSE
Default branch main
Open issues 0
Status Active

Skill metadata

Parsed from SKILL.md frontmatter.

Version0.1.0
More metadata
author
surrealdb
version
0.1.0

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,404 B
  • docs SUMMARY.md 445 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 361 installs

SKILL.md

SurrealDB Vector Search

HNSW Index

Create a basic HNSW index:

DEFINE INDEX hnsw_idx ON pts FIELDS point HNSW DIMENSION 4;

With specific distance function and type:

DEFINE INDEX hnsw_idx ON pts FIELDS point HNSW DIMENSION 4 DIST EUCLIDEAN TYPE F64;

Available types: F64, F32, I64, I32, I16.

Full Table Example

DEFINE TABLE OVERWRITE document SCHEMALESS;
DEFINE FIELD OVERWRITE embedding ON document TYPE array<float>;
DEFINE INDEX OVERWRITE hnsw_idx_document ON document
    FIELDS embedding
    HNSW DIMENSION 384
    DIST COSINE
    TYPE F32
    EFC 150 M 12 M0 24;

HNSW Parameters

Parameter Description
DIMENSION Vector dimensionality (must match your embeddings)
DIST Distance function: COSINE, EUCLIDEAN, etc.
TYPE Numeric type: F64, F32, I64, I32, I16
EFC Construction search effort (higher = better index)
M Max connections per node
M0 Max connections at layer 0

Querying Vectors

The <|K, EF|> operator performs KNN search. K is the number of results, EF is the search effort (higher = more accurate, slower).

Recommended effort values:

  • 40 — default, good accuracy
  • 17 — fast but may miss some results

Basic KNN Query

SELECT
    *,
    vector::distance::knn() AS dist
FROM document
WHERE embedding <|10, 40|> $vector;

vector::distance::knn() uses the distance function defined by the index.

Scored Results with Threshold

SELECT *, score
FROM (
    SELECT *, (1 - vector::distance::knn()) AS score
    FROM document
    WHERE embedding <|20, 40|> $vector
)
WHERE score >= $threshold
ORDER BY score DESC;