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

# Narsil vs OpenSearch

> The benchmark harness measured Narsil and OpenSearch for ranking quality, speed, and ingest. Every result is here, including OpenSearch's wins.

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

## Headline result

On DBpedia 1M keyword search with equal settings, Narsil answers 1.7 times as many searches a second as OpenSearch.

Ratio: 1.7× (OpenSearch's rate).

- Narsil Rust: 11,792
- Narsil TypeScript: 8,459
- OpenSearch: 7,013

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 OpenSearch `3.10.0`.

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

## What each engine is for

**OpenSearch.** OpenSearch is a distributed search and analytics engine that began as a fork of Elasticsearch, and the OpenSearch Software Foundation at the Linux Foundation governs it. Teams use it for application search, log analytics, and vector search, and AWS offers it as a managed service.

**Narsil.** Narsil is an open source search engine for application search, with full-text, vector, hybrid, and geo search on one typed index. A Node.js application can embed it with no separate server, and any other application can call the same engine through its REST API.

## 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.

### Keyword search

| Dataset | Engine | nDCG@10 | Recall@100 | Ingest docs/s | p50 ms | p99 ms | Peak QPS |
| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: |
| SciFact | Narsil TypeScript | 0.681 | 0.925 | 4,421 | 0.34 | 0.80 | 34,198 (34,169 to 34,213) |
| SciFact | Narsil Rust | 0.681 | 0.925 | 7,529 | 0.26 | 0.40 | 56,315 (56,271 to 56,361) |
| SciFact | OpenSearch | 0.679 | 0.925 | 5,544 | 1.83 | 2.86 | 8,713 (8,667 to 8,734) |
| NFCorpus | Narsil TypeScript | 0.328 | 0.249 | 4,402 | 0.32 | 0.71 | 51,462 (51,319 to 51,564) |
| NFCorpus | Narsil Rust | 0.328 | 0.249 | 6,717 | 0.22 | 0.31 | 94,225+ (93,724 to 94,639) |
| NFCorpus | OpenSearch | 0.322 | 0.246 | 7,625 | 0.68 | 1.01 | 13,527 (13,524 to 13,537) |
| DBpedia 100K | Narsil TypeScript | n/a | n/a | 18,039 | 0.30 | 0.64 | 33,054 (32,983 to 33,102) |
| DBpedia 100K | Narsil Rust | n/a | n/a | 35,693 | 0.24 | 0.52 | 53,510 (53,422 to 53,637) |
| DBpedia 100K | OpenSearch | n/a | n/a | 45,892 | 0.66 | 1.05 | 13,435 (13,356 to 13,461) |
| DBpedia 1M | Narsil TypeScript | n/a | n/a | 18,512 | 0.54 | 2.12 | 8,459 (8,380 to 8,498) |
| DBpedia 1M | Narsil Rust | n/a | n/a | 22,032 | 0.58 | 1.99 | 11,792 (11,749 to 11,803) |
| DBpedia 1M | OpenSearch | n/a | n/a | 45,484 | 0.93 | 2.04 | 7,013 (6,997 to 7,073) |

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.

A + after a peak means that the load generator reached its limit before the engine did, so the engine's real peak is at least that figure.

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

### 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 | OpenSearch | 0.624 | 0.923 | 0.997 | 1,070 | 0.87 | 1.53 | 7,957 (7,946 to 7,980) |
| 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 | OpenSearch | 0.315 | 0.309 | 0.995 | 1,141 | 0.95 | 1.12 | 7,563 (7,551 to 7,567) |
| 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 | OpenSearch | n/a | n/a | 0.992 | 362 | 1.86 | 2.37 | 3,219 (3,188 to 3,222) |
| 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 | OpenSearch | n/a | n/a | 0.991 | 228 | 3.50 | 5.82 | 1,719 (1,694 to 1,753) |

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 | OpenSearch | 0.708 | 0.961 | 1,064 | 1.97 | 2.70 | 3,352 (3,347 to 3,371) |
| 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 | OpenSearch | 0.352 | 0.321 | 1,092 | 1.47 | 1.96 | 4,356 (4,351 to 4,365) |
| 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 | OpenSearch | n/a | n/a | 373 | 2.33 | 3.64 | 2,449 (2,445 to 2,481) |
| 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 | OpenSearch | n/a | n/a | 220 | 4.30 | 7.25 | 1,396 (1,392 to 1,403) |

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 | OpenSearch | 0.624 | 0.923 | 0.996 | SQfp16 | 1,123 | 0.86 | 1.05 | 8,117 (8,113 to 8,180) |
| 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 | OpenSearch | 0.315 | 0.309 | 0.993 | SQfp16 | 1,205 | 0.93 | 1.13 | 7,743 (7,685 to 7,763) |
| 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 | OpenSearch | n/a | n/a | 0.992 | 1-bit binary | 693 | 1.32 | 1.59 | 5,168 (5,160 to 5,185) |
| 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 | OpenSearch | n/a | n/a | 0.990 | 1-bit binary | 556 | 2.94 | 6.14 | 2,849 (2,673 to 3,018) |

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 | OpenSearch | 0.706 | 0.961 | SQfp16 | 1,069 | 1.77 | 2.50 | 3,353 (3,342 to 3,362) |
| 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 | OpenSearch | 0.352 | 0.322 | SQfp16 | 1,202 | 1.44 | 1.86 | 4,395 (4,347 to 4,435) |
| 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 | OpenSearch | n/a | n/a | 1-bit binary | 694 | 1.77 | 2.16 | 3,515 (3,508 to 3,549) |
| 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 | OpenSearch | n/a | n/a | 1-bit binary | 561 | 3.88 | 9.79 | 1,952 (1,945 to 2,019) |

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 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.
- When you add AI, Narsil retrieves the passages for your model and highlights the matched text, so you can trace every claim in an answer back to a document.

Of the 140 measurements that the harness recorded for both engines, Narsil came out ahead in 118 and OpenSearch in 14, 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 20.

| Comparison | Narsil | OpenSearch |
| --- | ---: | ---: |
| Keyword, SciFact (equal, Narsil TypeScript) | 0.681 | 0.679 |
| Keyword, SciFact (equal, Narsil Rust) | 0.681 | 0.679 |
| Keyword, NFCorpus (equal, Narsil TypeScript) | 0.328 | 0.322 |
| Keyword, NFCorpus (equal, Narsil Rust) | 0.328 | 0.322 |
| Hybrid, NFCorpus (equal, Narsil TypeScript) | 0.356 | 0.352 |
| Hybrid, NFCorpus (equal, Narsil Rust) | 0.356 | 0.352 |
| Hybrid, NFCorpus (recommended, Narsil TypeScript) | 0.356 | 0.352 |
| Hybrid, NFCorpus (recommended, Narsil Rust) | 0.356 | 0.352 |

### Peak queries a second

Narsil better in 38 of 40.

| Comparison | Narsil | OpenSearch |
| --- | ---: | ---: |
| Keyword, SciFact (equal, Narsil TypeScript) | 34,198 | 8,713 |
| Keyword, SciFact (equal, Narsil Rust) | 56,315 | 8,713 |
| Keyword, NFCorpus (equal, Narsil TypeScript) | 51,462 | 13,527 |
| Keyword, NFCorpus (equal, Narsil Rust) | 94,225 | 13,527 |
| Keyword, DBpedia 100K (equal, Narsil TypeScript) | 33,054 | 13,435 |
| Keyword, DBpedia 100K (equal, Narsil Rust) | 53,510 | 13,435 |
| Keyword, DBpedia 1M (equal, Narsil TypeScript) | 8,459 | 7,013 |
| Keyword, DBpedia 1M (equal, Narsil Rust) | 11,792 | 7,013 |
| Vector, SciFact (equal, Narsil TypeScript) | 16,931 | 7,957 |
| Vector, SciFact (equal, Narsil Rust) | 27,162 | 7,957 |
| Vector, NFCorpus (equal, Narsil TypeScript) | 13,799 | 7,563 |
| Vector, NFCorpus (equal, Narsil Rust) | 21,238 | 7,563 |
| Vector, DBpedia 100K (equal, Narsil TypeScript) | 3,589 | 3,219 |
| Vector, DBpedia 100K (equal, Narsil Rust) | 4,794 | 3,219 |
| Vector, DBpedia 1M (equal, Narsil Rust) | 1,971 | 1,719 |
| Hybrid, SciFact (equal, Narsil TypeScript) | 11,835 | 3,352 |
| Hybrid, SciFact (equal, Narsil Rust) | 19,998 | 3,352 |
| Hybrid, NFCorpus (equal, Narsil TypeScript) | 11,604 | 4,356 |
| Hybrid, NFCorpus (equal, Narsil Rust) | 18,913 | 4,356 |
| Hybrid, DBpedia 100K (equal, Narsil TypeScript) | 3,218 | 2,449 |
| Hybrid, DBpedia 100K (equal, Narsil Rust) | 4,647 | 2,449 |
| Hybrid, DBpedia 1M (equal, Narsil Rust) | 1,614 | 1,396 |
| Vector, SciFact (recommended, Narsil TypeScript) | 15,809 | 8,117 |
| Vector, SciFact (recommended, Narsil Rust) | 30,671 | 8,117 |
| Vector, NFCorpus (recommended, Narsil TypeScript) | 13,309 | 7,743 |
| Vector, NFCorpus (recommended, Narsil Rust) | 23,795 | 7,743 |
| Vector, DBpedia 100K (recommended, Narsil TypeScript) | 5,522 | 5,168 |
| Vector, DBpedia 100K (recommended, Narsil Rust) | 9,341 | 5,168 |
| Vector, DBpedia 1M (recommended, Narsil TypeScript) | 3,766 | 2,849 |
| Vector, DBpedia 1M (recommended, Narsil Rust) | 3,847 | 2,849 |
| Hybrid, SciFact (recommended, Narsil TypeScript) | 10,572 | 3,353 |
| Hybrid, SciFact (recommended, Narsil Rust) | 21,782 | 3,353 |
| Hybrid, NFCorpus (recommended, Narsil TypeScript) | 10,784 | 4,395 |
| Hybrid, NFCorpus (recommended, Narsil Rust) | 21,494 | 4,395 |
| Hybrid, DBpedia 100K (recommended, Narsil TypeScript) | 4,789 | 3,515 |
| Hybrid, DBpedia 100K (recommended, Narsil Rust) | 8,433 | 3,515 |
| Hybrid, DBpedia 1M (recommended, Narsil TypeScript) | 2,492 | 1,952 |
| Hybrid, DBpedia 1M (recommended, Narsil Rust) | 2,756 | 1,952 |

### Median client latency, ms

Narsil better in 40 of 40.

| Comparison | Narsil | OpenSearch |
| --- | ---: | ---: |
| Keyword, SciFact (equal, Narsil TypeScript) | 0.34 | 1.83 |
| Keyword, SciFact (equal, Narsil Rust) | 0.26 | 1.83 |
| Keyword, NFCorpus (equal, Narsil TypeScript) | 0.32 | 0.68 |
| Keyword, NFCorpus (equal, Narsil Rust) | 0.22 | 0.68 |
| Keyword, DBpedia 100K (equal, Narsil TypeScript) | 0.30 | 0.66 |
| Keyword, DBpedia 100K (equal, Narsil Rust) | 0.24 | 0.66 |
| Keyword, DBpedia 1M (equal, Narsil TypeScript) | 0.54 | 0.93 |
| Keyword, DBpedia 1M (equal, Narsil Rust) | 0.58 | 0.93 |
| Vector, SciFact (equal, Narsil TypeScript) | 0.46 | 0.87 |
| Vector, SciFact (equal, Narsil Rust) | 0.37 | 0.87 |
| Vector, NFCorpus (equal, Narsil TypeScript) | 0.50 | 0.95 |
| Vector, NFCorpus (equal, Narsil Rust) | 0.44 | 0.95 |
| Vector, DBpedia 100K (equal, Narsil TypeScript) | 1.49 | 1.86 |
| Vector, DBpedia 100K (equal, Narsil Rust) | 1.41 | 1.86 |
| Vector, DBpedia 1M (equal, Narsil TypeScript) | 3.45 | 3.50 |
| Vector, DBpedia 1M (equal, Narsil Rust) | 3.18 | 3.50 |
| Hybrid, SciFact (equal, Narsil TypeScript) | 0.68 | 1.97 |
| Hybrid, SciFact (equal, Narsil Rust) | 0.50 | 1.97 |
| Hybrid, NFCorpus (equal, Narsil TypeScript) | 0.63 | 1.47 |
| Hybrid, NFCorpus (equal, Narsil Rust) | 0.49 | 1.47 |
| Hybrid, DBpedia 100K (equal, Narsil TypeScript) | 1.62 | 2.33 |
| Hybrid, DBpedia 100K (equal, Narsil Rust) | 1.46 | 2.33 |
| Hybrid, DBpedia 1M (equal, Narsil TypeScript) | 4.01 | 4.30 |
| Hybrid, DBpedia 1M (equal, Narsil Rust) | 3.76 | 4.30 |
| Vector, SciFact (recommended, Narsil TypeScript) | 0.39 | 0.86 |
| Vector, SciFact (recommended, Narsil Rust) | 0.34 | 0.86 |
| Vector, NFCorpus (recommended, Narsil TypeScript) | 0.43 | 0.93 |
| Vector, NFCorpus (recommended, Narsil Rust) | 0.41 | 0.93 |
| Vector, DBpedia 100K (recommended, Narsil TypeScript) | 0.86 | 1.32 |
| Vector, DBpedia 100K (recommended, Narsil Rust) | 0.78 | 1.32 |
| Vector, DBpedia 1M (recommended, Narsil TypeScript) | 1.58 | 2.94 |
| Vector, DBpedia 1M (recommended, Narsil Rust) | 1.77 | 2.94 |
| Hybrid, SciFact (recommended, Narsil TypeScript) | 0.61 | 1.77 |
| Hybrid, SciFact (recommended, Narsil Rust) | 0.47 | 1.77 |
| Hybrid, NFCorpus (recommended, Narsil TypeScript) | 0.61 | 1.44 |
| Hybrid, NFCorpus (recommended, Narsil Rust) | 0.43 | 1.44 |
| Hybrid, DBpedia 100K (recommended, Narsil TypeScript) | 1.02 | 1.77 |
| Hybrid, DBpedia 100K (recommended, Narsil Rust) | 0.91 | 1.77 |
| Hybrid, DBpedia 1M (recommended, Narsil TypeScript) | 2.56 | 3.88 |
| Hybrid, DBpedia 1M (recommended, Narsil Rust) | 2.49 | 3.88 |

### Documents ingested a second

Narsil better in 32 of 40.

| Comparison | Narsil | OpenSearch |
| --- | ---: | ---: |
| Keyword, SciFact (equal, Narsil Rust) | 7,529 | 5,544 |
| Vector, SciFact (equal, Narsil TypeScript) | 1,691 | 1,070 |
| Vector, SciFact (equal, Narsil Rust) | 2,374 | 1,070 |
| Vector, NFCorpus (equal, Narsil TypeScript) | 1,564 | 1,141 |
| Vector, NFCorpus (equal, Narsil Rust) | 2,273 | 1,141 |
| Vector, DBpedia 100K (equal, Narsil TypeScript) | 850 | 362 |
| Vector, DBpedia 100K (equal, Narsil Rust) | 886 | 362 |
| Vector, DBpedia 1M (equal, Narsil TypeScript) | 743 | 228 |
| Vector, DBpedia 1M (equal, Narsil Rust) | 878 | 228 |
| Hybrid, SciFact (equal, Narsil TypeScript) | 1,989 | 1,064 |
| Hybrid, SciFact (equal, Narsil Rust) | 2,333 | 1,064 |
| Hybrid, NFCorpus (equal, Narsil TypeScript) | 1,590 | 1,092 |
| Hybrid, NFCorpus (equal, Narsil Rust) | 2,093 | 1,092 |
| Hybrid, DBpedia 100K (equal, Narsil TypeScript) | 855 | 373 |
| Hybrid, DBpedia 100K (equal, Narsil Rust) | 879 | 373 |
| Hybrid, DBpedia 1M (equal, Narsil TypeScript) | 704 | 220 |
| Hybrid, DBpedia 1M (equal, Narsil Rust) | 880 | 220 |
| Vector, SciFact (recommended, Narsil TypeScript) | 2,100 | 1,123 |
| Vector, SciFact (recommended, Narsil Rust) | 2,367 | 1,123 |
| Vector, NFCorpus (recommended, Narsil TypeScript) | 1,562 | 1,205 |
| Vector, NFCorpus (recommended, Narsil Rust) | 1,995 | 1,205 |
| Vector, DBpedia 100K (recommended, Narsil TypeScript) | 818 | 693 |
| Vector, DBpedia 100K (recommended, Narsil Rust) | 879 | 693 |
| Vector, DBpedia 1M (recommended, Narsil Rust) | 882 | 556 |
| Hybrid, SciFact (recommended, Narsil TypeScript) | 2,012 | 1,069 |
| Hybrid, SciFact (recommended, Narsil Rust) | 2,398 | 1,069 |
| Hybrid, NFCorpus (recommended, Narsil TypeScript) | 1,626 | 1,202 |
| Hybrid, NFCorpus (recommended, Narsil Rust) | 1,939 | 1,202 |
| Hybrid, DBpedia 100K (recommended, Narsil TypeScript) | 812 | 694 |
| Hybrid, DBpedia 100K (recommended, Narsil Rust) | 876 | 694 |
| Hybrid, DBpedia 1M (recommended, Narsil TypeScript) | 572 | 561 |
| Hybrid, DBpedia 1M (recommended, Narsil Rust) | 881 | 561 |

## Where OpenSearch is better

- A foundation with many member companies governs OpenSearch, so no single vendor controls its roadmap.
- OpenSearch Dashboards and the OpenSearch plugins cover log analytics, visualisation, alerting, and security analytics.
- Amazon OpenSearch Service operates OpenSearch clusters on AWS and handles their backups and scaling for you.

Measurements that OpenSearch won:

### nDCG@10

OpenSearch better in 4 of 20.

| Comparison | Narsil | OpenSearch |
| --- | ---: | ---: |
| Hybrid, SciFact (equal, Narsil TypeScript) | 0.705 | 0.708 |
| Hybrid, SciFact (equal, Narsil Rust) | 0.705 | 0.708 |
| Hybrid, SciFact (recommended, Narsil TypeScript) | 0.705 | 0.706 |
| Hybrid, SciFact (recommended, Narsil Rust) | 0.705 | 0.706 |

### Peak queries a second

OpenSearch better in 2 of 40.

| Comparison | Narsil | OpenSearch |
| --- | ---: | ---: |
| Vector, DBpedia 1M (equal, Narsil TypeScript) | 1,659 | 1,719 |
| Hybrid, DBpedia 1M (equal, Narsil TypeScript) | 1,304 | 1,396 |

### Documents ingested a second

OpenSearch better in 8 of 40.

| Comparison | Narsil | OpenSearch |
| --- | ---: | ---: |
| Keyword, SciFact (equal, Narsil TypeScript) | 4,421 | 5,544 |
| Keyword, NFCorpus (equal, Narsil TypeScript) | 4,402 | 7,625 |
| Keyword, NFCorpus (equal, Narsil Rust) | 6,717 | 7,625 |
| Keyword, DBpedia 100K (equal, Narsil TypeScript) | 18,039 | 45,892 |
| Keyword, DBpedia 100K (equal, Narsil Rust) | 35,693 | 45,892 |
| Keyword, DBpedia 1M (equal, Narsil TypeScript) | 18,512 | 45,484 |
| Keyword, DBpedia 1M (equal, Narsil Rust) | 22,032 | 45,484 |
| Vector, DBpedia 1M (recommended, Narsil TypeScript) | 542 | 556 |

## 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 opensearch
```

- [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)
