A high-performance, full-featured text search engine library written in Java
open sourceApache-2.0self-hostablefree
Apache Lucene is the Apache Software Foundation's full-text search library for Java: an application embeds it to build and query an inverted index, rather than talking to a search server. It ranks results with pluggable models (BM25, the vector space model), handles phrase, wildcard, proximity and range queries, fielded search and sorting, faceting, highlighting, joins and result grouping, typo-tolerant suggesters and spell correction, and nearest-neighbour search over high-dimensional vectors, with storage formats pluggable through codecs. It is the engine inside Apache Solr, Elasticsearch and OpenSearch, and PyLucene, a sibling Apache project, wraps it for Python. Version 10 needs Java 21 or later; the 9.x line still gets releases.
Problems it solves
- add full-text search with BM25 ranking to my Java application without running a separate search server
- embed a search index in a JVM app that supports phrase, wildcard, proximity and range queries
- nearest-neighbour vector search inside a Java library for semantic search over my embeddings
- faceted navigation and hit highlighting for search results in a Java or Kotlin app
- typo-tolerant autocomplete suggestions for a search box, built into my Java backend
- index hundreds of gigabytes of text quickly with a small memory footprint
- build my own search engine on the same core library that Elasticsearch and Solr are built on
- keep searching an index while new documents are still being added and updated
- group search results by a field or join parent and child documents in an embedded index
- plug a custom scoring model into my application's text search ranking
- use a mature full-text search library from Python through bindings
Features
- incremental indexing as fast as batch indexing; index about 20-30% of the text's size
- ranked search with pluggable models including BM25 and the vector space model
- phrase, wildcard, proximity, range and fielded queries; sorting by any field
- multi-index search with merged results
- search while updating
- faceting, highlighting, joins and result grouping
- nearest-neighbour search over high-dimensional vectors
- fast, memory-efficient, typo-tolerant suggesters and spell correction
- configurable storage engine through codecs
- PyLucene: Python bindings (a separate Apache Lucene project)
Alternatives
The same job
These do what Apache Lucene does.
- Tantivy Fast full-text search engine library written in Rust
- Bleve Full-text, geo and vector search library for Go
- pg_textsearch PostgreSQL extension for BM25 relevance-ranked full-text search
