# Apache Lucene

**Apache Lucene** 是一个完全用 Java 编写的自由开源搜索引擎库，提供全文索引、结构化搜索、分面、拼写纠正以及高维向量上的最近邻搜索。它不是一个完整的应用程序，而是一个代码库和 API，供应用程序嵌入以添加搜索能力，并且是 [Apache Solr](https://www.edgepedia.org/zh/apache-solr)、[Elasticsearch](https://www.edgepedia.org/zh/elasticsearch) 和 OpenSearch 的搜索核心。<sup>[1](https://lucene.apache.org/core/corenews.html)</sup><sup> • </sup><sup>[2](https://lucene.apache.org/)</sup><sup> • </sup><sup>[3](https://lucene.apache.org/core/10_5_0/index.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 原始作者 | 道格·卡廷，他此前曾在施乐帕洛阿尔托研究中心、苹果和 Excite@Home 构建搜索引擎，于 1997 年末至 1998 年初利用业余时间编写了 Lucene<sup>[4](https://svn.apache.org/repos/asf/lucene/java/branches/lucene_2_0/docs/whoweare.html)</sup> |
| 首个开源版本 | 0.01 版，2000 年 3 月 30 日，发布于 SourceForge；首个 Apache 版本 1.2 RC1 于 2001 年 10 月 2 日发布<sup>[5](https://lucene.apache.org/core/3_1_0/changes/Changes.html)</sup> |
| Apache 地位 | 自 2005 年 1 月起成为顶级项目；截至 2026 年 6 月的董事会报告，其拥有 112 名提交者和 70 名 PMC 成员<sup>[6](https://apache.org/foundation/board/minutes/Lucene.html)</sup> |
| 索引模型 | 由独立段组成的倒排索引；文档由在每个段内按顺序分配的整数 docid 标识<sup>[7](https://lucene.apache.org/core/3_3_0/fileformats.html)</sup><sup> • </sup><sup>[8](https://lucene.apache.org/core/10_5_2/core/org/apache/lucene/index/package-summary.html)</sup> |
| 默认排序 | BM25 相似度，参数 k1 = 1.2、b = 0.75；经典的向量空间 TF-IDF 评分仍然可用<sup>[9](https://lucene.apache.org/core/7_3_0/core/org/apache/lucene/search/similarities/BM25Similarity.html)</sup><sup> • </sup><sup>[10](https://lucene.apache.org/core/10_3_0/core/org/apache/lucene/search/similarities/package-summary.html)</sup> |
| 当前版本 | 10.x 系列上的 10.5.2（2026 年 10 月 4 日），要求 Java 21 或更高版本；9.12.3 是最新的 9.x 版本<sup>[1](https://lucene.apache.org/core/corenews.html)</sup><sup> • </sup><sup>[11](https://lucene.apache.org/core/10_0_0/SYSTEM_REQUIREMENTS.html)</sup> |
| 下游系统 | Apache Solr、Elasticsearch 和 OpenSearch 均构建于 Lucene 核心之上<sup>[2](https://lucene.apache.org/)</sup> |

## 历史

道格·卡廷是一位搜索工程师，此前曾在施乐帕洛阿尔托研究中心、苹果和 Excite@Home 构建过搜索引擎，他在 1997 年末至 1998 年初学习 Java 期间利用业余时间编写了 Lucene。<sup>[4](https://svn.apache.org/repos/asf/lucene/java/branches/lucene_2_0/docs/whoweare.html)</sup><sup> • </sup><sup>[12](https://www.elastic.co/kr/celebrating-lucene)</sup> 他于 2000 年在 [SourceForge](https://www.edgepedia.org/zh/sourceforge) 上将其作为开源软件发布，最初采用 GPL，后改为 LGPL；0.01 版于 2000 年 3 月 30 日面世，1.0 版于 2000 年 10 月 4 日发布。<sup>[12](https://www.elastic.co/kr/celebrating-lucene)</sup><sup> • </sup><sup>[5](https://lucene.apache.org/core/3_1_0/changes/Changes.html)</sup>

**迁往 Apache。** Lucene 于 2001 年加入 Apache Jakarta 家族。首个 Apache 版本 1.2 RC1（2001 年 10 月 2 日）将包名从 `com.lucene` 改为 `org.apache.lucene`，并将许可证从 LGPL 切换为 Apache 许可证。<sup>[5](https://lucene.apache.org/core/3_1_0/changes/Changes.html)</sup> 2005 年 1 月 19 日，Apache 软件基金会董事会将 Lucene 确立为顶级项目，将其从 Jakarta 中分离出来。<sup>[6](https://apache.org/foundation/board/minutes/Lucene.html)</sup>

**Lucene 家族。** 作为顶级项目，Lucene 孕育了一系列相关工作，卡廷在 2000 年代中期向 ASF 董事会报告了这些工作：Nutch，一个基于爬虫的网页搜索引擎；Hadoop，卡廷于 2006 年提议将其作为新子项目，将 Nutch 的分布式计算组件（[MapReduce](https://www.edgepedia.org/zh/mapreduce) 和 NDFS）解耦出来；Solr，一个基于 CNET 捐赠的软件构建的企业搜索服务器，由 Lucene 提交者约尼克·西利领导；Lucy，一个共享的基于 C 的核心，用于移植到 Perl、Python 和 Ruby 等语言；Lucene.NET，一个 C# 移植版；以及 Tika，一个用于检测和提取文档元数据及结构化文本内容的工具包。<sup>[6](https://apache.org/foundation/board/minutes/Lucene.html)</sup> Hadoop 后来本身发展成为一个重要的分布式计算项目，雅虎于 2006 年在超过 600 台机器的集群上展示了其可扩展性。<sup>[6](https://www.apache.org/foundation/board/minutes/Lucene.html)</sup>

**Solr 的分离。** 多年来，Solr 与 Lucene 同步开发和发布。这种情况在 2021 年结束：2021 年 12 月 7 日发布的 Lucene 9.0.0 是 Solr 分离为独立顶级项目后的首个版本，Solr 现在在 solr.apache.org 开发。<sup>[6](https://www.apache.org/foundation/board/minutes/Lucene.html)</sup><sup> • </sup><sup>[2](https://lucene.apache.org/)</sup>

## 索引的工作原理

Lucene 的数据结构是倒排索引：不是文档列出其词项，而是索引为每个词项列出包含它的文档，以及使基于词项的搜索高效的词项统计信息。<sup>[7](https://lucene.apache.org/core/3_3_0/fileformats.html)</sup> 基本概念是索引、文档、字段和词项：索引包含一系列文档，文档是一系列字段，字段是一个有名称的词项序列，词项是一个字符串，由其字段限定，因此两个不同字段中的相同文本算作两个不同的词项。<sup>[7](https://lucene.apache.org/core/3_3_0/fileformats.html)</sup> 字段可以被存储，意味着其文本按字面保留在索引中，或者被索引，意味着它们被倒排；大多数文本字段在索引前由分析器分词为词项。<sup>[7](https://lucene.apache.org/core/3_3_0/fileformats.html)</sup><sup> • </sup><sup>[13](https://archive.apache.org/dist/lucene/solr/ref-guide/apache-solr-ref-guide-6.2.pdf)</sup>

**段。** 一个 Lucene 索引由段组成，每个段是文档子集上的一个完整、可独立搜索的索引。随着文档被写入，新段被创建并刷新到存储；删除和文档值更新会创建新段，这些新段与它们所修改的段共享相同的不可变核心，更新实现为原子插入和删除。随着时间的推移，写入器将较小的段组合并为较大的段，以保持索引搜索高效并回收已删除文档留下的死空间。<sup>[8](https://lucene.apache.org/core/10_5_2/core/org/apache/lucene/index/package-summary.html)</sup> `IndexWriter` 类创建和维护索引，当 RAM 使用量或文档数达到配置阈值时刷新缓冲文档，并默认在后台线程中运行合并；其合并策略（默认是一种分层策略，仅当已删除文档超过 10% 时才选择段进行强制合并）和合并调度器都是可插拔的。<sup>[14](https://lucene.apache.org/core/10_5_0/core/org/apache/lucene/index/IndexWriter.html)</sup>

**文档标识符。** 每个文档携带一个 32 位 docid，在其段内从零开始按顺序分配。文档的全局 docid 是其每段 docid 与段基偏移量之和。由于合并会重新分配 docid，它们是内部实现细节，应用程序不得在 Lucene 之外存储或引用它们。<sup>[8](https://lucene.apache.org/core/10_5_2/core/org/apache/lucene/index/package-summary.html)</sup>

## 评分

Lucene 通过 `Similarity` 类暴露的可插拔排序模型对文档进行评分。默认是 `BM25Similarity`，即 1994 年在 TREC-3 上提出的 [Okapi BM25](https://www.edgepedia.org/zh/okapi-bm25) 模型的优化实现，有两个可调参数：`k1`，用于校准词频饱和度（默认 1.2，设为 0 则完全忽略词频），以及 `b`，控制文档长度对词频归一化的强度（默认 0.75，设为 0 则禁用长度归一化）。<sup>[9](https://lucene.apache.org/core/7_3_0/core/org/apache/lucene/search/similarities/BM25Similarity.html)</sup><sup> • </sup><sup>[15](https://lucene.apache.org/core/9_4_2/core/org/apache/lucene/search/similarities/package-summary.html)</sup> `ClassicSimilarity` 是基于向量空间模型和 TF-IDF 的原始 Lucene 评分函数，仍然可用，该包还附带基于阿马蒂和赖斯伯根的 DFR 框架及其他模型的排序方法；可以通过扩展 `SimilarityBase` 编写新的排序函数。<sup>[10](https://lucene.apache.org/core/10_3_0/core/org/apache/lucene/search/similarities/package-summary.html)</sup> Lucene 的评分历史上将向量空间模型与首先缩小待评分文档集的布尔模型相结合。<sup>[16](https://lucene.apache.org/core/2_9_4/scoring.pdf)</sup>

## 向量搜索

除词项索引外，Lucene 使用分层可导航小世界（HNSW）图提供稠密向量上的近似最近邻搜索，实现在 `org.apache.lucene.util.hnsw` 包中，为高维向量提供高效的近似最近邻搜索。<sup>[17](https://lucene.apache.org/core/10_5_2/core/org/apache/lucene/util/hnsw/package-summary.html)</sup> 研究表明，在 [MS MARCO](https://www.edgepedia.org/zh/ms-marco) 段落排名集合上，Lucene 的 HNSW 索引足以在标准双编码器架构中使用 OpenAI 嵌入进行向量搜索，此后 Lucene 的 HNSW 索引已被集成到 Anserini 工具包中，用于可复现的信息检索研究。<sup>[18](https://arxiv.org/abs/2308.14963)</sup><sup> • </sup><sup>[19](https://arxiv.org/abs/2304.12139)</sup> 最近的版本继续在这方面投入：Lucene 10.2.0 加速了 HNSW 图合并，在该项目的夜间基准测试中转化为 25% 的索引速度提升，10.5.0 增加了混合搜索查询，使用贝叶斯概率组合来自不同索引类型的分数，例如 BM25 和向量分数。<sup>[20](https://cwiki.apache.org/confluence/download/export/pdfexport-20260604-040626-0253-195881/Releases%2BNotes%2B10.2.0_46f41fe4a2ee4d1ba7708504064bdccb-040626-0253-195882.pdf?contentType=application%2Fpdf)</sup><sup> • </sup><sup>[1](https://lucene.apache.org/core/corenews.html)</sup>

## 项目与发布

Lucene 由 Apache 软件基金会下的志愿者开发；由于其自愿性质，没有预先安排的发布计划，官方版本在开发者判断有足够变更时出现。<sup>[21](https://lucene.apache.org/core/downloads.html)</sup> 10.x 系列始于 2024 年 10 月 14 日的 Lucene 10.0.0，并于 2026 年 10 月 4 日达到 10.5.2，这是一个错误修复版本，修复了 HNSW 向量搜索召回率方面的问题、Hunspell 分析器性能问题以及 `SortedNumericDocValuesRangeQuery` 的一处缺陷；10.5.0 本身增加了实验性列式批量索引 API，并在批量评分和过滤中更广泛地使用 SIMD 指令。<sup>[22](https://cwiki.apache.org/confluence/download/export/pdfexport-20260604-040626-1052-204673/Release%2BNotes%2B10.0.0_6a08dab3a0ec47cc909f3876f1513e85-040626-1052-204674.pdf?contentType=application%2Fpdf)</sup><sup> • </sup><sup>[1](https://lucene.apache.org/core/corenews.html)</sup> Lucene 10 要求 Java 21 或更高版本。<sup>[11](https://lucene.apache.org/core/10_0_0/SYSTEM_REQUIREMENTS.html)</sup> 社区规模稳步增长：该项目报告 2019 年有 82 名提交者和 53 名 PMC 成员，2021 年末有 91 名提交者和 61 名 PMC 成员，2026 年 6 月有 112 名提交者和 70 名 PMC 成员。<sup>[6](https://apache.org/foundation/board/minutes/Lucene.html)</sup>

## 生态系统

Lucene 作为嵌入式库而非服务器的角色塑造了其生态系统。Apache Solr 是构建在 Lucene 之上的搜索服务器，增加了可网络访问的引擎，以及通过分布式搜索和索引复制扩展到单机之外的能力。<sup>[23](https://solr.apache.org/guide/solr/latest/getting-started/introduction.html)</sup><sup> • </sup><sup>[24](https://solr.apache.org/docs/6_6_2/)</sup> Elasticsearch 和 OpenSearch 同样在底层使用 Lucene，这就是为什么 Lucene 被描述为所有三个系统的搜索核心。<sup>[2](https://lucene.apache.org/)</sup> 移植版将该模型扩展到其他平台：Lucene.NET 是 .NET 平台上的 C# 移植版，PyLucene 提供 Python 绑定，[Apache Doris](https://www.edgepedia.org/zh/apache-doris) 在 CLucene（Lucene 的 C++ 移植版）上构建其列级倒排索引。<sup>[6](https://apache.org/foundation/board/minutes/Lucene.html)</sup><sup> • </sup><sup>[25](https://release-catalog.apache.org/lucene/index.html)</sup><sup> • </sup><sup>[26](https://doris.apache.org/docs/4.x/key-features/inverted-index/)</sup> Lucene 也被用作研究基础：Anserini 和 Pyserini 工具包支持直接在 Lucene 索引上进行可复现的信息检索实验，Search Benchmark, the Game 等比较基准评估 Lucene 与其他引擎的对比。<sup>[19](https://arxiv.org/abs/2304.12139)</sup><sup> • </sup><sup>[27](https://lucene.apache.org/core/)</sup>

## References

1. [Apache Lucene - Lucene Core News](https://lucene.apache.org/core/corenews.html)
2. [Apache Lucene - Welcome to Apache Lucene](https://lucene.apache.org/)
3. [Apache Lucene 10.5.0 Documentation](https://lucene.apache.org/core/10_5_0/index.html)
4. [Apache Lucene - Who We Are (Lucene 2.0 branch)](https://svn.apache.org/repos/asf/lucene/java/branches/lucene_2_0/docs/whoweare.html)
5. [Lucene Change Log (3.1.0, historical releases)](https://lucene.apache.org/core/3_1_0/changes/Changes.html)
6. [Board history: Lucene, Apache Software Foundation](https://apache.org/foundation/board/minutes/Lucene.html)
7. [Apache Lucene - Index File Formats (3.3.0)](https://lucene.apache.org/core/3_3_0/fileformats.html)
8. [org.apache.lucene.index package summary (Lucene 10.5.2 core API)](https://lucene.apache.org/core/10_5_2/core/org/apache/lucene/index/package-summary.html)
9. [BM25Similarity (Lucene 7.3.0 API)](https://lucene.apache.org/core/7_3_0/core/org/apache/lucene/search/similarities/BM25Similarity.html)
10. [org.apache.lucene.search.similarities package summary (Lucene 10.3.0)](https://lucene.apache.org/core/10_3_0/core/org/apache/lucene/search/similarities/package-summary.html)
11. [System Requirements (Lucene 10.0.0)](https://lucene.apache.org/core/10_0_0/SYSTEM_REQUIREMENTS.html)
12. [Celebrating 20 years of Apache Lucene, Elastic](https://www.elastic.co/kr/celebrating-lucene)
13. [Understanding Analyzers, Tokenizers, and Filters, Apache Solr Reference Guide 6.2](https://archive.apache.org/dist/lucene/solr/ref-guide/apache-solr-ref-guide-6.2.pdf)
14. [IndexWriter (Lucene 10.5.0 core API)](https://lucene.apache.org/core/10_5_0/core/org/apache/lucene/index/IndexWriter.html)
15. [org.apache.lucene.search.similarities package summary (Lucene 9.4.2)](https://lucene.apache.org/core/9_4_2/core/org/apache/lucene/search/similarities/package-summary.html)
16. [Apache Lucene - Scoring (2.9.4)](https://lucene.apache.org/core/2_9_4/scoring.pdf)
17. [org.apache.lucene.util.hnsw package summary (Lucene 10.5.2)](https://lucene.apache.org/core/10_5_2/core/org/apache/lucene/util/hnsw/package-summary.html)
18. [Vector Search with OpenAI Embeddings: Lucene Is All You Need (arXiv:2308.14963)](https://arxiv.org/abs/2308.14963)
19. [Anserini Gets Dense Retrieval: Integration of Lucene's HNSW Indexes (arXiv:2304.12139)](https://arxiv.org/abs/2304.12139)
20. [Release Notes 10.2.0, Apache Lucene](https://cwiki.apache.org/confluence/download/export/pdfexport-20260604-040626-0253-195881/Releases%2BNotes%2B10.2.0_46f41fe4a2ee4d1ba7708504064bdccb-040626-0253-195882.pdf?contentType=application%2Fpdf)
21. [Apache Lucene - Lucene Downloads](https://lucene.apache.org/core/downloads.html)
22. [Release Notes 10.0.0, Apache Lucene](https://cwiki.apache.org/confluence/download/export/pdfexport-20260604-040626-1052-204673/Release%2BNotes%2B10.0.0_6a08dab3a0ec47cc909f3876f1513e85-040626-1052-204674.pdf?contentType=application%2Fpdf)
23. [Introduction to Solr, Apache Solr Reference Guide](https://solr.apache.org/guide/solr/latest/getting-started/introduction.html)
24. [Apache Solr 6.6.2 Documentation](https://solr.apache.org/docs/6_6_2/)
25. [Apache Lucene Release Catalog, Apache Software Foundation](https://release-catalog.apache.org/lucene/index.html)
26. [Inverted Index, Apache Doris documentation](https://doris.apache.org/docs/4.x/key-features/inverted-index/)
27. [Apache Lucene - Apache Lucene Core](https://lucene.apache.org/core/)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Named software products and platforms › Search, maps, email, and productivity services

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/apache-lucene

English original: https://www.edgepedia.org/apache-lucene
