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

# Narsil vs Weaviate

> The benchmark harness measured Narsil and Weaviate on the same vectors for recall, speed, and ingest. Every result is here, including Weaviate's wins.

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

## Headline result

On DBpedia 1M hybrid search with equal settings, Narsil answers 4.2 times as many searches a second as Weaviate.

Ratio: 4.2× (Weaviate's rate).

- Narsil Rust: 1,614
- Narsil TypeScript: 1,304
- Weaviate: 380

The DBpedia 1M set contains no human relevance judgements, so the harness reports no nDCG@10 for it.

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

The harness measured Narsil `0.4.5` against Weaviate `1.40.5`.

The harness tested Narsil TypeScript on GCP c3-standard-8, us-central1-a; Narsil Rust on GCP c3-standard-8, us-east1-b; and Weaviate on GCP c3-standard-8, us-west3-b, each on the processor that its machine reports as Intel(R) Xeon(R) Platinum 8481C CPU @ 2.70GHz.

## What each engine is for

**Weaviate.** Weaviate is an open source vector database written in Go that stores each object together with its vector. Its modules can call an embedding provider when you import data, and you can deploy it yourself or use Weaviate Cloud.

**Narsil.** Narsil searches vectors, full text, and both at once in one typed index. You can embed it in a TypeScript, Python, Go, or Rust process, where a vector search needs no network call, or you can deploy the same engine as a server.

## Equal settings

Every engine stores full-precision vectors. On the vector track, the harness raises each engine's search effort until that engine reaches an ANN recall@10 of 0.99, before it measures the engine's speed.

### Vector search

| Dataset | Engine | nDCG@10 | Recall@100 | ANN recall@10 | Ingest docs/s | p50 ms | p99 ms | Peak QPS |
| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| SciFact | Narsil TypeScript | 0.624 | 0.923 | 0.996 | 1,691 | 0.46 | 0.82 | 16,931 (16,925 to 16,999) |
| SciFact | Narsil Rust | 0.624 | 0.923 | 0.996 | 2,374 | 0.37 | 0.49 | 27,162 (27,054 to 27,221) |
| SciFact | Weaviate | 0.624 | 0.923 | 0.997 | 1,673 | 2.29 | 4.81 | 1,788 (1,788 to 1,791) |
| NFCorpus | Narsil TypeScript | 0.315 | 0.309 | 0.994 | 1,564 | 0.50 | 0.93 | 13,799 (13,794 to 14,027) |
| NFCorpus | Narsil Rust | 0.315 | 0.309 | 0.991 | 2,273 | 0.44 | 0.54 | 21,238 (21,167 to 21,265) |
| NFCorpus | Weaviate | 0.315 | 0.309 | 0.993 | 1,379 | 2.40 | 5.33 | 1,684 (1,681 to 1,689) |
| DBpedia 100K | Narsil TypeScript | n/a | n/a | 0.991 | 850 | 1.49 | 2.18 | 3,589 (3,567 to 3,592) |
| DBpedia 100K | Narsil Rust | n/a | n/a | 0.991 | 886 | 1.41 | 1.93 | 4,794 (4,660 to 5,195) |
| DBpedia 100K | Weaviate | n/a | n/a | 0.992 | 656 | 7.30 | 10.77 | 616 (615 to 617) |
| DBpedia 1M | Narsil TypeScript | n/a | n/a | 0.992 | 743 | 3.45 | 4.79 | 1,659 (1,631 to 1,663) |
| DBpedia 1M | Narsil Rust | n/a | n/a | 0.992 | 878 | 3.18 | 4.37 | 1,971 (1,849 to 2,005) |
| DBpedia 1M | Weaviate | n/a | n/a | 0.993 | 668 | 10.86 | 13.37 | 476 (476 to 480) |

A highlighted figure is the best in its column for that dataset.

p50 is the median search time and p99 is the time within which 99% of searches finished, as the client measured them. The table shows each peak with its 95% interval.

The tables show n/a for nDCG@10 and Recall@100 on the DBpedia sets, because those sets contain no human relevance judgements.

### Hybrid search

| Dataset | Engine | nDCG@10 | Recall@100 | Ingest docs/s | p50 ms | p99 ms | Peak QPS |
| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: |
| SciFact | Narsil TypeScript | 0.705 | 0.964 | 1,989 | 0.68 | 1.07 | 11,835 (11,798 to 11,838) |
| SciFact | Narsil Rust | 0.705 | 0.964 | 2,333 | 0.50 | 0.63 | 19,998 (19,936 to 20,005) |
| SciFact | Weaviate | 0.684 | 0.958 | 1,652 | 3.19 | 6.87 | 842 (840 to 843) |
| NFCorpus | Narsil TypeScript | 0.356 | 0.324 | 1,590 | 0.63 | 1.02 | 11,604 (11,578 to 11,613) |
| NFCorpus | Narsil Rust | 0.356 | 0.324 | 2,093 | 0.49 | 0.63 | 18,913 (18,884 to 18,916) |
| NFCorpus | Weaviate | 0.343 | 0.319 | 1,441 | 3.06 | 7.47 | 1,019 (1,018 to 1,020) |
| DBpedia 100K | Narsil TypeScript | n/a | n/a | 855 | 1.62 | 2.37 | 3,218 (3,172 to 3,228) |
| DBpedia 100K | Narsil Rust | n/a | n/a | 879 | 1.46 | 1.98 | 4,647 (4,423 to 4,736) |
| DBpedia 100K | Weaviate | n/a | n/a | 662 | 8.00 | 11.30 | 513 (509 to 520) |
| DBpedia 1M | Narsil TypeScript | n/a | n/a | 704 | 4.01 | 6.18 | 1,304 (1,280 to 1,310) |
| DBpedia 1M | Narsil Rust | n/a | n/a | 880 | 3.76 | 5.50 | 1,614 (1,596 to 1,650) |
| DBpedia 1M | Weaviate | n/a | n/a | 668 | 16.78 | 36.38 | 380 (372 to 381) |

A highlighted figure is the best in its column for that dataset.

p50 is the median search time and p99 is the time within which 99% of searches finished, as the client measured them. The table shows each peak with its 95% interval.

The tables show n/a for nDCG@10 and Recall@100 on the DBpedia sets, because those sets contain no human relevance judgements.

## Recommended production settings

Each engine stores vectors in the compressed form that its documentation recommends for production, which the Vector storage column shows. However, each engine has to reach an ANN recall@10 of 0.99 before the harness measures its speed.

### Vector search

| Dataset | Engine | nDCG@10 | Recall@100 | ANN recall@10 | Vector storage | Ingest docs/s | p50 ms | p99 ms | Peak QPS |
| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| SciFact | Narsil TypeScript | 0.624 | 0.923 | 0.993 | OSQ 4-bit | 2,100 | 0.39 | 0.76 | 15,809 (15,756 to 15,840) |
| SciFact | Narsil Rust | 0.624 | 0.923 | 0.995 | OSQ 4-bit | 2,367 | 0.34 | 0.47 | 30,671 (30,602 to 30,696) |
| SciFact | Weaviate | 0.624 | 0.923 | 0.997 | 8-bit RQ | 1,768 | 2.38 | 5.74 | 1,663 (1,653 to 1,667) |
| NFCorpus | Narsil TypeScript | 0.315 | 0.309 | 0.993 | OSQ 4-bit | 1,562 | 0.43 | 0.80 | 13,309 (13,273 to 13,336) |
| NFCorpus | Narsil Rust | 0.315 | 0.309 | 0.993 | OSQ 4-bit | 1,995 | 0.41 | 0.54 | 23,795 (23,768 to 23,836) |
| NFCorpus | Weaviate | 0.315 | 0.309 | 0.993 | 8-bit RQ | 1,424 | 2.46 | 5.56 | 1,606 (1,605 to 1,606) |
| DBpedia 100K | Narsil TypeScript | n/a | n/a | 0.992 | OSQ 4-bit | 818 | 0.86 | 1.38 | 5,522 (5,462 to 5,536) |
| DBpedia 100K | Narsil Rust | n/a | n/a | 0.991 | OSQ 4-bit | 879 | 0.78 | 1.01 | 9,341 (9,285 to 9,465) |
| DBpedia 100K | Weaviate | n/a | n/a | 0.992 | 8-bit RQ | 657 | 6.87 | 12.01 | 609 (608 to 609) |
| DBpedia 1M | Narsil TypeScript | n/a | n/a | 0.992 | OSQ 4-bit | 542 | 1.58 | 2.33 | 3,766 (3,586 to 3,931) |
| DBpedia 1M | Narsil Rust | n/a | n/a | 0.992 | OSQ 4-bit | 882 | 1.77 | 2.36 | 3,847 (3,716 to 3,879) |
| DBpedia 1M | Weaviate | n/a | n/a | 0.992 | 8-bit RQ | 668 | 8.86 | 11.82 | 534 (531 to 537) |

A highlighted figure is the best in its column for that dataset.

p50 is the median search time and p99 is the time within which 99% of searches finished, as the client measured them. The table shows each peak with its 95% interval.

The tables show n/a for nDCG@10 and Recall@100 on the DBpedia sets, because those sets contain no human relevance judgements.

### Hybrid search

| Dataset | Engine | nDCG@10 | Recall@100 | Vector storage | Ingest docs/s | p50 ms | p99 ms | Peak QPS |
| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| SciFact | Narsil TypeScript | 0.705 | 0.964 | OSQ 4-bit | 2,012 | 0.61 | 0.92 | 10,572 (10,571 to 10,709) |
| SciFact | Narsil Rust | 0.705 | 0.964 | OSQ 4-bit | 2,398 | 0.47 | 0.61 | 21,782 (21,769 to 21,888) |
| SciFact | Weaviate | 0.684 | 0.958 | 8-bit RQ | 1,701 | 3.35 | 8.57 | 781 (779 to 792) |
| NFCorpus | Narsil TypeScript | 0.356 | 0.324 | OSQ 4-bit | 1,626 | 0.61 | 0.95 | 10,784 (10,711 to 10,926) |
| NFCorpus | Narsil Rust | 0.356 | 0.324 | OSQ 4-bit | 1,939 | 0.43 | 0.58 | 21,494 (21,487 to 21,504) |
| NFCorpus | Weaviate | 0.343 | 0.319 | 8-bit RQ | 1,429 | 3.22 | 8.03 | 953 (952 to 955) |
| DBpedia 100K | Narsil TypeScript | n/a | n/a | OSQ 4-bit | 812 | 1.02 | 1.62 | 4,789 (4,749 to 4,795) |
| DBpedia 100K | Narsil Rust | n/a | n/a | OSQ 4-bit | 876 | 0.91 | 1.21 | 8,433 (8,425 to 8,540) |
| DBpedia 100K | Weaviate | n/a | n/a | 8-bit RQ | 664 | 7.75 | 15.20 | 478 (477 to 479) |
| DBpedia 1M | Narsil TypeScript | n/a | n/a | OSQ 4-bit | 572 | 2.56 | 6.42 | 2,492 (2,471 to 2,508) |
| DBpedia 1M | Narsil Rust | n/a | n/a | OSQ 4-bit | 881 | 2.49 | 4.14 | 2,756 (2,752 to 2,761) |
| DBpedia 1M | Weaviate | n/a | n/a | 8-bit RQ | 669 | 10.13 | 13.62 | 371 (369 to 374) |

A highlighted figure is the best in its column for that dataset.

p50 is the median search time and p99 is the time within which 99% of searches finished, as the client measured them. The table shows each peak with its 95% interval.

The tables show n/a for nDCG@10 and Recall@100 on the DBpedia sets, because those sets contain no human relevance judgements.

## Where Narsil is better

- Narsil ranks keyword matches with BM25 in the same index as your vectors, then fuses both rankings into one list for a hybrid search.
- Narsil can work inside your application process, where it answers each search without a network call. Once you need a server, a Narsil server can load that same index without any change.
- The same engine works in a browser and stores its index in IndexedDB, so your users can search while their device is offline.

Of the 112 measurements that the harness recorded for both engines, Narsil came out ahead in 102 and Weaviate in 2, while 8 came out level.

A peak is level when the two 95% intervals overlap, or when the load generator capped the lower peak, because that figure is then a lower bound. Every other measure is level when the tables above show the same figure for both engines.

### nDCG@10

Narsil better in 8 of 16.

| Comparison | Narsil | Weaviate |
| --- | ---: | ---: |
| Hybrid, SciFact (equal, Narsil TypeScript) | 0.705 | 0.684 |
| Hybrid, SciFact (equal, Narsil Rust) | 0.705 | 0.684 |
| Hybrid, NFCorpus (equal, Narsil TypeScript) | 0.356 | 0.343 |
| Hybrid, NFCorpus (equal, Narsil Rust) | 0.356 | 0.343 |
| Hybrid, SciFact (recommended, Narsil TypeScript) | 0.705 | 0.684 |
| Hybrid, SciFact (recommended, Narsil Rust) | 0.705 | 0.684 |
| Hybrid, NFCorpus (recommended, Narsil TypeScript) | 0.356 | 0.343 |
| Hybrid, NFCorpus (recommended, Narsil Rust) | 0.356 | 0.343 |

### Peak queries a second

Narsil better in 32 of 32.

| Comparison | Narsil | Weaviate |
| --- | ---: | ---: |
| Vector, SciFact (equal, Narsil TypeScript) | 16,931 | 1,788 |
| Vector, SciFact (equal, Narsil Rust) | 27,162 | 1,788 |
| Vector, NFCorpus (equal, Narsil TypeScript) | 13,799 | 1,684 |
| Vector, NFCorpus (equal, Narsil Rust) | 21,238 | 1,684 |
| Vector, DBpedia 100K (equal, Narsil TypeScript) | 3,589 | 616 |
| Vector, DBpedia 100K (equal, Narsil Rust) | 4,794 | 616 |
| Vector, DBpedia 1M (equal, Narsil TypeScript) | 1,659 | 476 |
| Vector, DBpedia 1M (equal, Narsil Rust) | 1,971 | 476 |
| Hybrid, SciFact (equal, Narsil TypeScript) | 11,835 | 842 |
| Hybrid, SciFact (equal, Narsil Rust) | 19,998 | 842 |
| Hybrid, NFCorpus (equal, Narsil TypeScript) | 11,604 | 1,019 |
| Hybrid, NFCorpus (equal, Narsil Rust) | 18,913 | 1,019 |
| Hybrid, DBpedia 100K (equal, Narsil TypeScript) | 3,218 | 513 |
| Hybrid, DBpedia 100K (equal, Narsil Rust) | 4,647 | 513 |
| Hybrid, DBpedia 1M (equal, Narsil TypeScript) | 1,304 | 380 |
| Hybrid, DBpedia 1M (equal, Narsil Rust) | 1,614 | 380 |
| Vector, SciFact (recommended, Narsil TypeScript) | 15,809 | 1,663 |
| Vector, SciFact (recommended, Narsil Rust) | 30,671 | 1,663 |
| Vector, NFCorpus (recommended, Narsil TypeScript) | 13,309 | 1,606 |
| Vector, NFCorpus (recommended, Narsil Rust) | 23,795 | 1,606 |
| Vector, DBpedia 100K (recommended, Narsil TypeScript) | 5,522 | 609 |
| Vector, DBpedia 100K (recommended, Narsil Rust) | 9,341 | 609 |
| Vector, DBpedia 1M (recommended, Narsil TypeScript) | 3,766 | 534 |
| Vector, DBpedia 1M (recommended, Narsil Rust) | 3,847 | 534 |
| Hybrid, SciFact (recommended, Narsil TypeScript) | 10,572 | 781 |
| Hybrid, SciFact (recommended, Narsil Rust) | 21,782 | 781 |
| Hybrid, NFCorpus (recommended, Narsil TypeScript) | 10,784 | 953 |
| Hybrid, NFCorpus (recommended, Narsil Rust) | 21,494 | 953 |
| Hybrid, DBpedia 100K (recommended, Narsil TypeScript) | 4,789 | 478 |
| Hybrid, DBpedia 100K (recommended, Narsil Rust) | 8,433 | 478 |
| Hybrid, DBpedia 1M (recommended, Narsil TypeScript) | 2,492 | 371 |
| Hybrid, DBpedia 1M (recommended, Narsil Rust) | 2,756 | 371 |

### Median client latency, ms

Narsil better in 32 of 32.

| Comparison | Narsil | Weaviate |
| --- | ---: | ---: |
| Vector, SciFact (equal, Narsil TypeScript) | 0.46 | 2.29 |
| Vector, SciFact (equal, Narsil Rust) | 0.37 | 2.29 |
| Vector, NFCorpus (equal, Narsil TypeScript) | 0.50 | 2.40 |
| Vector, NFCorpus (equal, Narsil Rust) | 0.44 | 2.40 |
| Vector, DBpedia 100K (equal, Narsil TypeScript) | 1.49 | 7.30 |
| Vector, DBpedia 100K (equal, Narsil Rust) | 1.41 | 7.30 |
| Vector, DBpedia 1M (equal, Narsil TypeScript) | 3.45 | 10.86 |
| Vector, DBpedia 1M (equal, Narsil Rust) | 3.18 | 10.86 |
| Hybrid, SciFact (equal, Narsil TypeScript) | 0.68 | 3.19 |
| Hybrid, SciFact (equal, Narsil Rust) | 0.50 | 3.19 |
| Hybrid, NFCorpus (equal, Narsil TypeScript) | 0.63 | 3.06 |
| Hybrid, NFCorpus (equal, Narsil Rust) | 0.49 | 3.06 |
| Hybrid, DBpedia 100K (equal, Narsil TypeScript) | 1.62 | 8.00 |
| Hybrid, DBpedia 100K (equal, Narsil Rust) | 1.46 | 8.00 |
| Hybrid, DBpedia 1M (equal, Narsil TypeScript) | 4.01 | 16.78 |
| Hybrid, DBpedia 1M (equal, Narsil Rust) | 3.76 | 16.78 |
| Vector, SciFact (recommended, Narsil TypeScript) | 0.39 | 2.38 |
| Vector, SciFact (recommended, Narsil Rust) | 0.34 | 2.38 |
| Vector, NFCorpus (recommended, Narsil TypeScript) | 0.43 | 2.46 |
| Vector, NFCorpus (recommended, Narsil Rust) | 0.41 | 2.46 |
| Vector, DBpedia 100K (recommended, Narsil TypeScript) | 0.86 | 6.87 |
| Vector, DBpedia 100K (recommended, Narsil Rust) | 0.78 | 6.87 |
| Vector, DBpedia 1M (recommended, Narsil TypeScript) | 1.58 | 8.86 |
| Vector, DBpedia 1M (recommended, Narsil Rust) | 1.77 | 8.86 |
| Hybrid, SciFact (recommended, Narsil TypeScript) | 0.61 | 3.35 |
| Hybrid, SciFact (recommended, Narsil Rust) | 0.47 | 3.35 |
| Hybrid, NFCorpus (recommended, Narsil TypeScript) | 0.61 | 3.22 |
| Hybrid, NFCorpus (recommended, Narsil Rust) | 0.43 | 3.22 |
| Hybrid, DBpedia 100K (recommended, Narsil TypeScript) | 1.02 | 7.75 |
| Hybrid, DBpedia 100K (recommended, Narsil Rust) | 0.91 | 7.75 |
| Hybrid, DBpedia 1M (recommended, Narsil TypeScript) | 2.56 | 10.13 |
| Hybrid, DBpedia 1M (recommended, Narsil Rust) | 2.49 | 10.13 |

### Documents ingested a second

Narsil better in 30 of 32.

| Comparison | Narsil | Weaviate |
| --- | ---: | ---: |
| Vector, SciFact (equal, Narsil TypeScript) | 1,691 | 1,673 |
| Vector, SciFact (equal, Narsil Rust) | 2,374 | 1,673 |
| Vector, NFCorpus (equal, Narsil TypeScript) | 1,564 | 1,379 |
| Vector, NFCorpus (equal, Narsil Rust) | 2,273 | 1,379 |
| Vector, DBpedia 100K (equal, Narsil TypeScript) | 850 | 656 |
| Vector, DBpedia 100K (equal, Narsil Rust) | 886 | 656 |
| Vector, DBpedia 1M (equal, Narsil TypeScript) | 743 | 668 |
| Vector, DBpedia 1M (equal, Narsil Rust) | 878 | 668 |
| Hybrid, SciFact (equal, Narsil TypeScript) | 1,989 | 1,652 |
| Hybrid, SciFact (equal, Narsil Rust) | 2,333 | 1,652 |
| Hybrid, NFCorpus (equal, Narsil TypeScript) | 1,590 | 1,441 |
| Hybrid, NFCorpus (equal, Narsil Rust) | 2,093 | 1,441 |
| Hybrid, DBpedia 100K (equal, Narsil TypeScript) | 855 | 662 |
| Hybrid, DBpedia 100K (equal, Narsil Rust) | 879 | 662 |
| Hybrid, DBpedia 1M (equal, Narsil TypeScript) | 704 | 668 |
| Hybrid, DBpedia 1M (equal, Narsil Rust) | 880 | 668 |
| Vector, SciFact (recommended, Narsil TypeScript) | 2,100 | 1,768 |
| Vector, SciFact (recommended, Narsil Rust) | 2,367 | 1,768 |
| Vector, NFCorpus (recommended, Narsil TypeScript) | 1,562 | 1,424 |
| Vector, NFCorpus (recommended, Narsil Rust) | 1,995 | 1,424 |
| Vector, DBpedia 100K (recommended, Narsil TypeScript) | 818 | 657 |
| Vector, DBpedia 100K (recommended, Narsil Rust) | 879 | 657 |
| Vector, DBpedia 1M (recommended, Narsil Rust) | 882 | 668 |
| Hybrid, SciFact (recommended, Narsil TypeScript) | 2,012 | 1,701 |
| Hybrid, SciFact (recommended, Narsil Rust) | 2,398 | 1,701 |
| Hybrid, NFCorpus (recommended, Narsil TypeScript) | 1,626 | 1,429 |
| Hybrid, NFCorpus (recommended, Narsil Rust) | 1,939 | 1,429 |
| Hybrid, DBpedia 100K (recommended, Narsil TypeScript) | 812 | 664 |
| Hybrid, DBpedia 100K (recommended, Narsil Rust) | 876 | 664 |
| Hybrid, DBpedia 1M (recommended, Narsil Rust) | 881 | 669 |

## Where Weaviate is better

- Weaviate's modules can create embeddings for you at import and at query time.
- Weaviate accepts queries over GraphQL, REST, and gRPC, through official client libraries for several languages.
- Weaviate Cloud operates Weaviate for you.

Measurements that Weaviate won:

### Documents ingested a second

Weaviate better in 2 of 32.

| Comparison | Narsil | Weaviate |
| --- | ---: | ---: |
| Vector, DBpedia 1M (recommended, Narsil TypeScript) | 542 | 668 |
| Hybrid, DBpedia 1M (recommended, Narsil TypeScript) | 572 | 669 |

## 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/benchmarks/server
./run-all.sh narsil narsil-rust weaviate
```

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