@moss-js/moss) brings semantic search to Node.js. It wraps a
high-performance Rust core and exposes an async, Promise-based API. Documents are embedded
and queried locally, with optional cloud sync.
Requirements
- Node.js 20.4 or higher
Install
Versions below 1.9.0 will stop loading models when the legacy download path is retired. Upgrade to 1.9.0+ before then.
Moss for Node moved from
@moss-dev/moss to @moss-js/moss with 1.8.0. @moss-dev/moss is a frozen 1.7.1 package. Versions below 1.9.0 will stop loading models when the legacy download path is retired. Upgrade to @moss-js/moss 1.9.0+ before then. The date will be announced in the changelog. @moss-dev/moss-web is the browser SDK and is not this package.projectId and projectKey from the Moss portal.
Two ways to search
MossClient- the entry point. Manage cloud indexes, load one into memory, and query it.SessionIndex- a local, in-process index for real-time indexing during a live interaction; push to the cloud when done.
Quick start
Indexes
Create, inspect, and delete cloud indexes. Mutations run as async jobs and return aMutationResult with a jobId and docCount.
Index from files
Build an index straight from PDF and DOCX files - the server parses, chunks, and embeds them. Up to 20 files per call.Documents
Add, update, fetch, and remove documents on an existing index.Load and query
Load an index into memory, then query it in-process. CallloadIndex before querying.
Hybrid search
Blend semantic and keyword scoring withalpha (1.0 = semantic, 0.0 = keyword; default 0.8).
Metadata filtering
Narrow results by document metadata on a loaded index.$eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $near, composed with
$and / $or. See Metadata filtering.
Custom embeddings
Supply your own vectors withmodelId: 'custom' (each document carries embedding, and
queries pass embedding).
Sessions
Index and query locally in real time with aSessionIndex, then
push to the cloud. session() resumes an existing cloud index by name, or starts empty.
Keeping indexes fresh
Auto-refresh a loaded index (poll the cloud and hot-swap newer versions in automatically), and track async jobs.Authentication
Construct the client with aprojectKey for server-side use, or use a custom authenticator
to mint short-lived tokens for untrusted clients (getAuthToken()).
Models
moss-minilm(default) - fast, lightweightmoss-mediumlm- higher accuracycustom- supply your own embedding vectors viaDocumentInfo.embedding