> Complete content index: https://narsil.sondelali.com/llms.txt

# Narsil vs MiniSearch

> The benchmark harness measured Narsil and MiniSearch in Node.js for speed, ranking quality, and memory, and Narsil leads in every comparison.

URL: https://narsil.sondelali.com/compare/minisearch

## Headline result

When Narsil is embedded in a Node.js process, a keyword search over 50,000 documents takes a median of 0.129 ms.

Ratio: 34× (shorter median than MiniSearch).

- Narsil: 0.129 ms
- MiniSearch: 4.457 ms

A lower time means a faster search. On SciFact, Narsil ranks results at nDCG@10 0.684 and MiniSearch at 0.251.

The harness recorded these figures in run `20261119T135657Z` on 19 November 2026, with Narsil built from commit `3ad47df2c9c1`.

The harness measured Narsil `0.4.5` against MiniSearch `7.2.0`.

The harness tested each engine in a separate Node.js v24.22.3 process on GCP c3-standard-8, us-central1-a, on the processor that the machine reports as Intel(R) Xeon(R) Platinum 8481C CPU @ 2.70GHz.

## What each engine is for

**MiniSearch.** MiniSearch is a small full-text search engine written in JavaScript that keeps its index in memory and has no dependencies. It offers prefix search, fuzzy search, and auto-suggestions, and it works in browsers and in Node.js.

**Narsil.** Narsil also embeds in a JavaScript process, and it adds vector, hybrid, and geo search, typed filters, and facets to full-text search. When an application outgrows one process, the same engine can serve the index over HTTP.

## Keyword search

Each engine indexes the same FiQA documents and answers the same queries at each corpus size.

| Measure | Corpus | Narsil | MiniSearch |
| --- | --- | ---: | ---: |
| Documents inserted a second | 1,000 documents | 12,172 | 8,042 |
| Documents inserted a second | 10,000 documents | 13,584 | 6,840 |
| Documents inserted a second | 50,000 documents | 13,026 | 6,101 |
| Median search, ms | 1,000 documents | 0.049 | 0.079 |
| Median search, ms | 10,000 documents | 0.055 | 0.605 |
| Median search, ms | 50,000 documents | 0.129 | 4.457 |
| p95 search, ms | 1,000 documents | 0.112 | 0.511 |
| p95 search, ms | 10,000 documents | 0.128 | 3.383 |
| p95 search, ms | 50,000 documents | 0.468 | 28.965 |
| Heap and external memory, MB | 1,000 documents | 1.1 | 6.7 |
| Heap and external memory, MB | 10,000 documents | 6.6 | 41.6 |
| Heap and external memory, MB | 50,000 documents | 23.1 | 175.0 |

## Filtered search

Each query adds a category filter and a minimum score filter to the search words.

The harness recorded no filtered search figures for MiniSearch.

| Measure | Corpus | Narsil | MiniSearch |
| --- | --- | ---: | ---: |
| Median filtered search, ms | 1,000 documents | 0.052 | n/a |
| Median filtered search, ms | 10,000 documents | 0.075 | n/a |
| Median filtered search, ms | 50,000 documents | 0.150 | n/a |

## Ranking quality

Human relevance judgements on SciFact score each engine's top ten results.

| Measure | Corpus | Narsil | MiniSearch |
| --- | --- | ---: | ---: |
| nDCG@10 | SciFact | 0.684 | 0.251 |

## Saving and loading

Each engine saves its largest index in its standard save format, then loads the saved copy and answers a search.

| Measure | Corpus | Narsil | MiniSearch |
| --- | --- | ---: | ---: |
| Saved size, MB | 50,000 documents | 70.1 | 73.2 |
| Save, ms | 50,000 documents | 1,335 | 2,127 |
| Load and first search, ms | 50,000 documents | 532 | 1,528 |

## Changing documents

Each engine removes a slice of its largest index, answers a search, and inserts the same number of documents again.

| Measure | Corpus | Narsil | MiniSearch |
| --- | --- | ---: | ---: |
| Documents removed a second | 50,000 documents | 7,929 | 1,155 |
| Search after removal, ms | 50,000 documents | 0.191 | 4.290 |
| Documents inserted again a second | 50,000 documents | 9,723 | 5,732 |

## Where Narsil is better

- Narsil keeps text, vectors, and coordinates in one typed index, so a single query can combine text, vector, and geo conditions.
- Narsil keeps each index durable with a write-ahead log and checkpoints.
- Narsil packages for Python, Go, and Rust read the same index format, so services outside JavaScript can search the same index.

Of the 19 measurements that the harness recorded for both engines, Narsil came out ahead in 19 and MiniSearch in 0.

A measure is level when the tables above show the same figure for both engines.

### Documents inserted a second

Narsil better in 3 of 3.

| Comparison | Narsil | MiniSearch |
| --- | ---: | ---: |
| Keyword search, 1,000 documents | 12,172 | 8,042 |
| Keyword search, 10,000 documents | 13,584 | 6,840 |
| Keyword search, 50,000 documents | 13,026 | 6,101 |

### Median search, ms

Narsil better in 3 of 3.

| Comparison | Narsil | MiniSearch |
| --- | ---: | ---: |
| Keyword search, 1,000 documents | 0.049 | 0.079 |
| Keyword search, 10,000 documents | 0.055 | 0.605 |
| Keyword search, 50,000 documents | 0.129 | 4.457 |

### p95 search, ms

Narsil better in 3 of 3.

| Comparison | Narsil | MiniSearch |
| --- | ---: | ---: |
| Keyword search, 1,000 documents | 0.112 | 0.511 |
| Keyword search, 10,000 documents | 0.128 | 3.383 |
| Keyword search, 50,000 documents | 0.468 | 28.965 |

### Heap and external memory, MB

Narsil better in 3 of 3.

| Comparison | Narsil | MiniSearch |
| --- | ---: | ---: |
| Keyword search, 1,000 documents | 1.1 | 6.7 |
| Keyword search, 10,000 documents | 6.6 | 41.6 |
| Keyword search, 50,000 documents | 23.1 | 175.0 |

### nDCG@10

Narsil better in 1 of 1.

| Comparison | Narsil | MiniSearch |
| --- | ---: | ---: |
| Ranking quality, SciFact | 0.684 | 0.251 |

### Saved size, MB

Narsil better in 1 of 1.

| Comparison | Narsil | MiniSearch |
| --- | ---: | ---: |
| Saving and loading, 50,000 documents | 70.1 | 73.2 |

### Save, ms

Narsil better in 1 of 1.

| Comparison | Narsil | MiniSearch |
| --- | ---: | ---: |
| Saving and loading, 50,000 documents | 1,335 | 2,127 |

### Load and first search, ms

Narsil better in 1 of 1.

| Comparison | Narsil | MiniSearch |
| --- | ---: | ---: |
| Saving and loading, 50,000 documents | 532 | 1,528 |

### Documents removed a second

Narsil better in 1 of 1.

| Comparison | Narsil | MiniSearch |
| --- | ---: | ---: |
| Changing documents, 50,000 documents | 7,929 | 1,155 |

### Search after removal, ms

Narsil better in 1 of 1.

| Comparison | Narsil | MiniSearch |
| --- | ---: | ---: |
| Changing documents, 50,000 documents | 0.191 | 4.290 |

### Documents inserted again a second

Narsil better in 1 of 1.

| Comparison | Narsil | MiniSearch |
| --- | ---: | ---: |
| Changing documents, 50,000 documents | 9,723 | 5,732 |

## Where MiniSearch is better

- MiniSearch is a small library with no dependencies, so it adds little to a browser bundle.
- MiniSearch is written in plain JavaScript with no native code, so the same package works in every JavaScript runtime, while Narsil loads a native core outside the browser.

Measurements that MiniSearch won:

The harness recorded no measurement in which MiniSearch came out ahead.

## Try Narsil

When you paste this prompt into your coding agent, the agent will install the Narsil skill and the package, then build and test the search that your project needs.

```text
Read https://narsil.sondelali.com/agents.md and follow it to add Narsil search to this project.
```

If you prefer to write the code yourself, you can use the Narsil package for TypeScript, Python, Go, or Rust, since every package searches with the same engine. Each program indexes three films and finds the films from 1990 onwards whose title matches ronin, before it finds the two films whose embeddings are closest to a query vector.

```bash title="pnpm" tab="TypeScript"
pnpm add @delali/narsil
```

```bash title="pip" tab="Python"
pip install delali-narsil
```

```bash title="go get" tab="Go"
go get github.com/assetcorp/narsil/packages/go/engine@v0.2.1
```

```bash title="cargo" tab="Rust"
cargo add delali-narsil
```

```ts title="films.ts" tab="TypeScript"
import { createNarsil } from '@delali/narsil'

const narsil = await createNarsil()

await narsil.createIndex('films', {
  schema: { title: 'string', year: 'number', embedding: 'vector[3]' },
})

await narsil.insertBatch('films', [
  { id: 'heat', title: 'Heat', year: 1995, embedding: [0.9, 0.1, 0.2] },
  { id: 'ronin', title: 'Ronin', year: 1998, embedding: [0.8, 0.3, 0.1] },
  { id: 'solaris', title: 'Solaris', year: 1972, embedding: [0.1, 0.9, 0.7] },
])

const keyword = await narsil.query('films', { term: 'ronin', filters: { fields: { year: { gte: 1990 } } } })
console.log(keyword.count, keyword.hits[0].id)

const nearest = await narsil.query('films', {
  vector: { field: 'embedding', value: [0.85, 0.2, 0.15] },
  limit: 2,
})
for (const hit of nearest.hits) {
  console.log(hit.id, hit.score)
}

await narsil.shutdown()
```

```python title="films.py" tab="Python"
from narsil import Narsil

with Narsil() as engine:
    engine.create_index("films", {"schema": {"title": "string", "year": "number", "embedding": "vector[3]"}})
    engine.insert_batch(
        "films",
        [
            {"id": "heat", "title": "Heat", "year": 1995, "embedding": [0.9, 0.1, 0.2]},
            {"id": "ronin", "title": "Ronin", "year": 1998, "embedding": [0.8, 0.3, 0.1]},
            {"id": "solaris", "title": "Solaris", "year": 1972, "embedding": [0.1, 0.9, 0.7]},
        ],
    )

    keyword = engine.query("films", {"term": "ronin", "filters": {"fields": {"year": {"gte": 1990}}}})
    print(keyword["count"], keyword["hits"][0]["id"])

    nearest = engine.query("films", {"vector": {"field": "embedding", "value": [0.85, 0.2, 0.15]}, "limit": 2})
    for hit in nearest["hits"]:
        print(hit["id"], hit["score"])
```

```go title="main.go" tab="Go"
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/assetcorp/narsil/packages/go/engine"
)

func main() {
	if err := run(context.Background(), "./narsil-data"); err != nil {
		log.Fatal(err)
	}
}

func run(ctx context.Context, directory string) error {
	narsil, err := engine.New(ctx, engine.Config{
		Durability: &engine.DurabilityConfig{Directory: directory},
	})
	if err != nil {
		return err
	}
	defer narsil.Shutdown(ctx)

	err = narsil.CreateIndex(ctx, "films", engine.IndexConfig{
		Schema: engine.Schema{
			"title":     engine.FieldString,
			"year":      engine.FieldNumber,
			"embedding": engine.VectorFieldType(3),
		},
	})
	if err != nil {
		return err
	}

	_, err = narsil.InsertBatch(ctx, "films", []*engine.Document{
		engine.DocumentFromMap(map[string]any{"id": "heat", "title": "Heat", "year": 1995, "embedding": []float32{0.9, 0.1, 0.2}}),
		engine.DocumentFromMap(map[string]any{"id": "ronin", "title": "Ronin", "year": 1998, "embedding": []float32{0.8, 0.3, 0.1}}),
		engine.DocumentFromMap(map[string]any{"id": "solaris", "title": "Solaris", "year": 1972, "embedding": []float32{0.1, 0.9, 0.7}}),
	}, engine.InsertOptions{})
	if err != nil {
		return err
	}

	keyword, err := narsil.Query(ctx, "films", engine.QueryParams{
		Term: "ronin",
		Filters: &engine.FilterExpression{Fields: map[string]engine.FieldFilter{
			"year": {Gte: engine.NumberBound(1990)},
		}},
	})
	if err != nil {
		return err
	}
	fmt.Println(keyword.Count, keyword.Hits[0].ID)

	nearest, err := narsil.Query(ctx, "films", engine.QueryParams{
		Mode:   engine.SearchVector,
		Vector: &engine.VectorQueryConfig{Field: "embedding", Value: []float32{0.85, 0.2, 0.15}},
		Limit:  engine.Some(2),
	})
	if err != nil {
		return err
	}
	for _, hit := range nearest.Hits {
		fmt.Println(hit.ID, hit.Score.Or(0))
	}
	return nil
}
```

```rust title="main.rs" tab="Rust"
use narsil::{IndexConfig, Narsil, NarsilConfig, QueryParams, Value, VectorQuery, parse_json};

fn main() -> narsil::Result<()> {
    let engine = Narsil::open(NarsilConfig::default())?;
    engine.create_index(
        "films",
        IndexConfig {
            schema: parse_json(r#"{ "title": "string", "year": "number", "embedding": "vector[3]" }"#)?,
            ..IndexConfig::default()
        },
    )?;

    let films = [
        r#"{ "id": "heat", "title": "Heat", "year": 1995, "embedding": [0.9, 0.1, 0.2] }"#,
        r#"{ "id": "ronin", "title": "Ronin", "year": 1998, "embedding": [0.8, 0.3, 0.1] }"#,
        r#"{ "id": "solaris", "title": "Solaris", "year": 1972, "embedding": [0.1, 0.9, 0.7] }"#,
    ];
    let mut documents = Vec::new();
    for film in films {
        if let Value::Object(document) = parse_json(film)? {
            documents.push(document);
        }
    }
    engine.insert_batch("films", documents)?;

    let keyword = engine.query(
        "films",
        &QueryParams {
            term: Some("ronin".into()),
            filters: Some(parse_json(r#"{ "fields": { "year": { "gte": 1990 } } }"#)?),
            ..QueryParams::default()
        },
    )?;
    println!("{} {}", keyword.count, keyword.hits[0].id);

    let nearest = engine.query(
        "films",
        &QueryParams {
            vector: Some(VectorQuery {
                field: "embedding".into(),
                value: Some(vec![0.85, 0.2, 0.15]),
                ..VectorQuery::default()
            }),
            limit: Some(2),
            ..QueryParams::default()
        },
    )?;
    for hit in &nearest.hits {
        println!("{} {}", hit.id, hit.score.unwrap_or(0.0));
    }
    Ok(())
}
```

- [Serve Narsil over HTTP](https://narsil.sondelali.com/docs/http-server)

## Reproduce these numbers

The benchmark harness is in the Narsil repository, where it writes every figure that it measures into a new run directory.

```bash
git clone https://github.com/assetcorp/narsil.git
cd narsil
pnpm install
pnpm run build
pnpm --filter benchmarks bench
```

- [Open the run on GitHub](https://github.com/assetcorp/narsil/tree/main/benchmarks/in-process/results/runs/20261119T135657Z)
- [Compare every engine in BENCHMARKS.md](https://github.com/assetcorp/narsil/blob/main/BENCHMARKS.md)
