<!-- generated by build_articles.py — edit content/compare/lucene-vs-tantivy-vs-elasticsearch.md instead -->
---
title: "Lucene vs Tantivy vs Elasticsearch (2026): library or server"
canonical: "https://xerj.org/compare/lucene-vs-tantivy-vs-elasticsearch"
updated: "2026-11-15"
source: "content/compare/lucene-vs-tantivy-vs-elasticsearch.md"
---

# Lucene vs Tantivy vs Elasticsearch in 2026: search library or search server?

**Short answer** (updated 2026-11-15): Lucene vs Tantivy vs Elasticsearch: Lucene is a Java search library, Tantivy is a Rust library inspired by Lucene, and Elasticsearch is a server built on Lucene. Embed a library when search lives inside your program; run a server when many clients query over HTTP. XERJ is a server with its own Rust engine and an MCP server.

**Key number:** Tantivy reports startup under 10 ms and BM25 scoring, and leaves distributed search to Quickwit; Lucene had 3,613 GitHub stars and Tantivy 16,443 on 2026-11-15. (as of 2026-11-15; source: [github.com/quickwit-oss/tantivy](https://github.com/quickwit-oss/tantivy))

Last checked: 2026-11-15. Every third-party fact on this page was re-read from the tool's own docs or repository on that date.

**TL;DR** Lucene is a Java search library, Tantivy is a Rust search library inspired by Lucene, and Elasticsearch is a search server built on Lucene. Embed a library when search lives inside your own program. Run a server when many clients search over HTTP. XERJ is a new way for AI to search for data: a server with its own Rust engine, an Elasticsearch compatible API and an MCP server.

## Agent prompt

```text
Act as a coding agent. Read https://xerj.org/llms.txt and https://xerj.org/compare/lucene-vs-tantivy-vs-elasticsearch, then decide whether this project should embed Lucene or Tantivy, or run Elasticsearch or XERJ as a server, using the table on that page. If XERJ fits: install it, index this repository with xerj autoindex, and run one search. Report the choice and the reasons.
```

All three are strong choices; the real question is library or server. Lucene also powers Apache Solr and OpenSearch, compared in [Solr, Elasticsearch and OpenSearch compared](/compare/solr-vs-elasticsearch-vs-opensearch).

*Figure: Features from each project README and docs, checked 2026-11-15.*

## Side by side

| | Apache Lucene | Tantivy | Elasticsearch | XERJ |
|---|---|---|---|---|
| What it is | Java library | Rust library | server built on Lucene | server with its own Rust engine |
| Licence | Apache-2.0 | MIT | AGPL-3.0, SSPL or ELv2 | Apache-2.0 |
| Scoring | BM25 and others | BM25 | BM25 and others | BM25 |
| Vectors | HNSW nearest neighbour | not listed in its feature list | kNN | HNSW, lexical feature hashing by default |
| Interface | Java API, PyLucene | Rust API, tantivy-py | REST and query DSL | Elasticsearch API subset plus MCP |
| Runs as | inside your JVM | inside your binary | its own server | one static binary |
| Stars (2026-11-15) | 3,613 | 16,443 | 78,718 | 19,118 |

## When to choose Lucene instead

Choose Lucene when search lives inside a Java application and you want full control: structured and full-text search, faceting, nearest neighbour vector search, spell correction and pluggable ranking with BM25. It is the engine under Elasticsearch, OpenSearch and Solr.

## When to choose Tantivy instead

Choose Tantivy when you write Rust and want search inside your own binary, with startup under 10 ms, BM25, facets, range queries, aggregations and stemming for 17 Latin languages. Python users have tantivy-py. For a server on the same engine, Quickwit is built on Tantivy.

## When to choose Elasticsearch instead

Choose Elasticsearch when you want a ready server on Lucene with a REST API, a rich query DSL, Kibana and clustering, so many applications can share one search service. More options: [Elasticsearch alternatives](/compare/elasticsearch-alternatives).

## XERJ: a new way for AI to search for data

XERJ is a server with a from-scratch Rust engine, not a wrapper around Lucene or Tantivy; our source pinned XERJ vs Lucene document compares segments, postings, values, analysis, updates and HNSW placement. It speaks a subset of the Elasticsearch API, see [Elasticsearch API compatibility](/docs/api-es-compat). xerj autoindex parses code with tree-sitter: on an Apache Lucene checkout of 6,113 source files, single-threaded extraction ran at about 1,500 files per second. XERJ is single-node only, and its default embedder is lexical feature hashing, with --embed-mode neural for a MiniLM model.

## How this page was checked

Features come from each project's README and docs, read on 2026-11-15: lucene.apache.org, the Tantivy README and elastic.co. Star counts come from the GitHub REST API the same day. XERJ engine details come from docs/XERJ_VS_LUCENE.md in the XERJ repository.

## Try it with XERJ

Use the Copy the prompt button and paste it into your coding agent. It decides between a library and a server for your project and, if XERJ fits, indexes your repository and runs a search.

## Read next

[Solr, Elasticsearch and OpenSearch compared](/compare/solr-vs-elasticsearch-vs-opensearch), [OpenSearch alternatives 2026](/compare/opensearch-alternatives-2026) and [Elasticsearch alternatives](/compare/elasticsearch-alternatives).

## FAQ

### What is the difference between Lucene and Elasticsearch?

Lucene is a Java library you call from your own code. Elasticsearch is a server built on Lucene that adds a REST API, a query DSL, clustering, Kibana and operations tooling. If you want search over HTTP, run a server; if you want search inside your Java program, embed Lucene.

### Is Tantivy a replacement for Lucene?

For Rust programs, often yes. Tantivy is strongly inspired by Lucene, uses BM25 scoring and reports startup under 10 ms, which suits command line tools. It covers full-text search with facets, ranges and aggregations, and Lucene adds vector search and a wider analyzer set.

### Is Tantivy faster than Lucene?

Tantivy links its benchmark repository, search-benchmark-game, where you can run both on the same corpus. We did not run it for this page, so test with your own queries before you decide.

### Is there a Tantivy server like Elasticsearch?

Yes. Quickwit is the distributed search engine built on Tantivy by the same team, aimed at logs and traces on object storage with an Elasticsearch API subset.

### Where does XERJ fit?

XERJ is a search server with its own Rust engine, not a wrapper around Lucene or Tantivy. It speaks a subset of the Elasticsearch API, indexes folders with xerj autoindex and serves agents through xerj mcp. It is single-node only.

### How was this page checked?

Features come from each project's README and docs, read on 2026-11-15, and star counts from the GitHub REST API the same day. XERJ engine details come from our source pinned XERJ vs Lucene document.

## Evidence

- Apache Lucene is a high-performance, full-featured text search engine library written in Java; building it needs JDK 25. — [https://github.com/apache/lucene](https://github.com/apache/lucene)
- Lucene supports structured search, full-text search, faceting, nearest-neighbor search across high-dimensionality vectors, spell correction and query suggestions, with ranking models including Okapi BM25. — [https://lucene.apache.org/core/](https://lucene.apache.org/core/)
- Tantivy is a full-text search engine library written in Rust, strongly inspired by Lucene's design, and is not an off-the-shelf search engine server. It reports startup under 10 ms, BM25 scoring, stemming for 17 Latin languages, faceted search, range queries and aggregations. Distributed search is out of its scope; Quickwit is the distributed engine built on Tantivy. Python bindings are tantivy-py. — [https://github.com/quickwit-oss/tantivy](https://github.com/quickwit-oss/tantivy)
- Elasticsearch is a distributed search and analytics engine, scalable data store and vector database. Its default licence is a choice of AGPL-3.0, SSPL v1 or Elastic License 2.0. — [https://github.com/elastic/elasticsearch](https://github.com/elastic/elasticsearch)
- Elasticsearch is powered by Lucene. — [https://www.elastic.co/elasticsearch](https://www.elastic.co/elasticsearch)
- XERJ is a from-scratch Rust engine; Lucene 10.3.1 is an embeddable Java search library. Lucene places HNSW per segment, and XERJ uses an index-level HNSW for eligible plain queries with an exact fallback elsewhere. — `docs/XERJ_VS_LUCENE.md`
- On an Apache Lucene checkout of 6,113 source files and 51 MB, single-threaded in-process extraction runs at about 1,500 files per second. — `README.md`
- GitHub stars on 2026-11-15 from the GitHub REST API: Elasticsearch 78,718; XERJ 19,118; Tantivy 16,443; Lucene 3,613. — [https://api.github.com/repos/quickwit-oss/tantivy](https://api.github.com/repos/quickwit-oss/tantivy)

## Related

- [Solr vs Elasticsearch vs OpenSearch in 2026: three Lucene servers compared](/compare/solr-vs-elasticsearch-vs-opensearch)
- [Best Elasticsearch alternatives in 2026, with published tests](/compare/elasticsearch-alternatives)
- [OpenSearch alternatives in 2026: 7 open source search engines compared](/compare/opensearch-alternatives-2026)
- [ES-compatible API](/docs/api-es-compat)
- [Does XERJ support S3 storage, alerting or custom plugins yet?](/answers/does-xerj-support-s3-alerting-plugins) (same intent: search engine alternatives)
- [Is there a single-binary local search engine I can just run?](/answers/search-engine-without-docker) (same intent: search engine alternatives)
- [The best lightweight Elasticsearch-compatible search servers in 2026](/compare/best-lightweight-elasticsearch-compatible-server-2026) (same intent: search engine alternatives)
