Distributed search, reforged.

Add fast, relevant search to your app: full-text, vector, hybrid, and geo, in the same class as Elasticsearch and OpenSearch. Narsil runs as a search server, or embeds straight in your process with no network hop, all from a single npm package.

pnpm add -E @delali/narsil

Elasticsearch and OpenSearch are search servers you stand up and scale. Narsil is the same class of engine, and the one codebase also embeds in your process, in Node.js, Bun, Deno, or the browser. Multi-node cluster mode is in active development.

From install to first query in one file

Create an index with a typed schema, insert documents, and query with filters. The same engine runs embedded in Node.js, inside the browser, or behind the bundled HTTP server.

Read the getting started guide
search.ts
import { createNarsil } from '@delali/narsil'
 
const narsil = await createNarsil()
 
await narsil.createIndex('products', {
  schema: {
    title: 'string',
    description: 'string',
    price: 'number',
    inStock: 'boolean',
  },
  language: 'english',
})
 
await narsil.insert('products', {
  title: 'Mechanical Keyboard',
  description: 'Cherry MX Brown switches with PBT keycaps',
  price: 129.99,
  inStock: true,
})
 
const results = await narsil.query('products', {
  term: 'mechanical keyboard',
  filters: {
    fields: {
      inStock: { eq: true },
      price: { lte: 200 },
    },
  },
})

Ask your data, with sources

Narsil retrieves the passages, your model writes the answer, and the matched text stays beside the response so you can check the answer against its sources. The server-app example has this working end to end.

The Cmd+K search on this site runs on Narsil.

See what you can build
AskKeywordSemanticHybrid

Does vitamin D supplementation reduce respiratory infections?

The retrieved trials report a modest protective effect, strongest in participants who started with a deficiency and took daily doses rather than large single boluses.[1][2]

Sources

1SciFact #49830.88

...daily vitamin D reduced the risk of acute respiratory infection among all participants...

2SciFact #10270.81

...protective effects were strongest in those with a baseline deficiency...

2 sourceshybrid · 34 ms

One dependency covers the whole engine

Keyword, vector, hybrid, and geo queries run on the same typed index, and partitioning and persistence install with them as one npm package.

Full-text search
BM25 ranking calibrated against the Anserini reference configuration, with typed schemas, filters, boosts, and highlighting.
Vector search
An HNSW index answers dense nearest-neighbour queries, with embedding adapters for local models and OpenAI-compatible APIs.
Hybrid ranking
Keyword and vector results fuse through reciprocal rank fusion or a linear blend, tunable per query.
Geosearch
Index coordinates and query by radius or bounding box alongside text and vector conditions.
Partitions and workers
Large indexes shard across partitions and worker threads, and every query merges the shards back into one ranked list.
Durable persistence
A write-ahead log, checkpoints, and portable .nrsl snapshots move indexes between Node.js, the browser, and the server.

Measured against the engines you already run

A recorded continuous-integration run scores Narsil against Elasticsearch, Meilisearch, OpenSearch, Qdrant, Typesense, and Weaviate on BEIR datasets, with pinned versions and equal memory caps.

1,020

Queries per second

Peak keyword throughput on SciFact, ahead of Elasticsearch at 820 in the same run.

0.6781

nDCG@10 on SciFact

Ranking quality within 0.001 of Elasticsearch and OpenSearch on graded judgements.

6

Engines compared

Every engine runs from a pinned image under the same memory cap, one at a time.

Read the full benchmark results

Start building with Narsil

The documentation walks you from installation to production configuration.