问题描述
我是 Lucene 新手,想在 Maven 环境中直接从我的 Java 代码调用它.我已经尝试了一段时间来寻找可以下载和运行的工作示例.官网最新的教程是2013-Lucene 3.* https://cwiki.apache.org/confluence/display/lucene/LuceneFAQ#LuceneFAQ-HowdoIstartusingLucene?.Maven 中当前的最新版本是 8.5.1
.网络上的大多数非官方教程不包含版本号或完全限定名称.Lucene 似乎会频繁更改其 API、语法和名称,因此会出现编译错误、ClassNotFound 和删除的方法.我想知道:
I'm new to Lucene and want to call it directly from my Java code in a Maven environment. I have tried for some time to find working examples that I can download and run. The latest tutorial on the official site is 2013 - Lucene 3.* https://cwiki.apache.org/confluence/display/lucene/LuceneFAQ#LuceneFAQ-HowdoIstartusingLucene?. The current latest version in Maven is 8.5.1
. Most non-official tutorials on the web do not contain version numbers or Fully Qualified Names. Lucene appears to change its API, syntax, and names at frequent intervals so that compile errors, ClassNotFound, and deleted methods occur.
I'd like to know:
- 当前稳定版本
- 涉及的 Lucene 包(是否需要
lucene-query
包?) - 指向 2020 年适用于这些版本的代码的指针
推荐答案
最新版文档的主页是这里.这包括所有 javadoc 部分的链接(不同库的不同部分).
The home page for the latest version of the documentation is here. This includes links to all the javadoc sections (different sections for different libraries).
它还包含一些当前工作代码示例的链接(是的,从 pre-8 到 8+ 存在重大更改).如您所见,在这方面 wiki 可能不可靠.
It also includes links to some current working code examples (yes, there are breaking changes from pre-8 to 8+). The wiki can be unreliable in this regard, as you have seen.
main demo 可能是最好的起点查看工作代码示例.
The main demo is probably the best place to start to see working code examples.
具体见如何索引和如何搜索示例.
您需要哪些软件包完全取决于您要做什么.例如,您不太可能需要空间分析包,除非您知道自己需要它.
Which packages you need depends entirely on what you are trying to do. It's unlikely that you will need the spatial analysis package, for example, unless you know you need it.
我的 POM 通常包括这些:
My POM typically includes these:
<properties>
<lucene.version>8.5.0</lucene.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-icu</artifactId>
<version>${lucene.version}</version>
</dependency>
</dependencies>
有时我也使用这些:
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-suggest</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-highlighter</artifactId>
<version>${lucene.version}</version>
</dependency>
这篇关于使用最新版本 Lucene 的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!