Recern Vector · Documentation

Node.js

1.0.0 stabilizes native and portable APIs, validates numeric inputs and prevents stale handles from reaching replacement collections. TypeScript 5.2+ is required for disposal declarations. See policy, statistics, examples and failure behavior.

For the portable API (embedded Recern, Recern HTTP and Qdrant), see portable clients and release packages. The native API documented below retains its existing behavior.

Recern Vector 1.0.0 includes native Node-API 8 bindings, TypeScript definitions and asynchronous search. Use Node.js 22 or later.

Install a release build

Install the platform-selecting package from npm:

npm install @recern/[email protected]

Keep optional dependencies enabled. npm selects an exact-version native addon for Linux x64/ARM64 (glibc 2.35+), macOS Intel/Apple silicon or Windows x64. There is no binary-download install script. Linux musl and Windows ARM64 require a source build and are not advertised prebuilt targets.

Alternatively, choose a self-contained archive from the 1.0.0 release:

Platform Archive
Linux x64 recern-vector-1.0.0-node-linux-x64.tgz
Linux ARM64 recern-vector-1.0.0-node-linux-arm64.tgz
macOS Intel recern-vector-1.0.0-node-darwin-x64.tgz
macOS Apple silicon recern-vector-1.0.0-node-darwin-arm64.tgz
Windows x64 recern-vector-1.0.0-node-win32-x64.tgz

Each archive contains a package directory with the native binary, loader, types and package metadata. Verify its checksum against the release's SHA256SUMS, extract it, and load the directory with require('./package'). These are platform-specific builds, not a universal binary. On other platforms, build from source.

First database

Save this as example.cjs after installing the npm package:

const { Database } = require('@recern/vector');

async function main() {
  const db = Database.openOrCreate('docs.rvec');
  // Use a fresh path for this example; createCollection rejects an existing name.
  const docs = db.createCollection('docs', {
    dim: 3,
    metric: 'cosine',
    quantization: 'int8',
  });
  docs.upsert('a', new Float32Array([1, 0, 0]), { lang: 'en' });
  db.save(); // commits to the WAL

  const hits = await docs.searchAsync(new Float32Array([1, 0, 0]), 5, {
    filter: { $or: [{ lang: 'en' }, { lang: 'ru' }], $not: { hidden: true } },
  });
  console.log(hits);
  db.checkpoint(); // self-contained snapshot; pause writes before copying it
}

main().catch(error => { console.error(error); process.exitCode = 1; });

Run node example.cjs. On an existing database, open the collection with db.collection('docs') instead of creating it again.

API and concurrency

new Database(path) opens an existing database. Database.create, openOrCreate and openReadOnly are factories. Collections support upsert, atomic upsertMany, get, delete, search, searchAsync, explain, stats and compact. Full signatures are in index.d.ts.

searchAsync copies the input Float32Array and searches on a worker while holding a shared database lock. Synchronous mutations wait for active searches; other methods run on the calling thread. Use Node worker threads for large imports or saves. Read-only handles reject mutations. A stale writer must reopen before saving again.

Metadata must be JSON-compatible. Use strings for integer values outside JavaScript's safe integer range.

Build from source

With Node.js 22+ and Rust 1.89+:

git clone --branch v1.0.0 https://github.com/recerndata/recern-vector.git
cd recern-vector/crates/recern-vector-node
npm run build
npm test

This creates a native binary for the current host. See file format and durability for WAL recovery and checkpoint behavior, and filters for logical filter syntax.

Edit this page on GitHub