Hibernate Search 和 Lucene 哪一个更适合高效的自由文本搜索?

发布于 2024-11-03 14:50:37 字数 221 浏览 3 评论 0原文

我们正在使用 Spring MVC、Spring 和 Hibernate 开发一个 Web 应用程序。

我们需要为我们的应用程序添加高效的自由文本搜索功能。为此,我们正在考虑使用 Hibernate Search(它在底层使用 Lucene)或直接使用 lucene。

因为我们已经在应用程序中使用休眠,所以对我们来说最好的选择是什么?一种相对于另一种的优点和缺点是什么?

谢谢。

We are developing a web application using Spring MVC, Spring and Hibernate.

We need to add efficient free text search capabilities to our applications. For this we are thinking of using either Hibernate Search (it uses Lucene under the hood) or directly lucene.

What is the best option for us as we are already using hibernate in our application? What are the pros and cons of one over the other?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暮年慕年 2024-11-10 14:50:37

您自己说过 - 您将以一种或另一种方式使用 Lucene。

原始的 Lucene API 不太容易使用。它比 Hibernate Search 低级得多。如果您已经在使用 Hibernate,那么这是显而易见的 - 使用 Hibernate Search 来实现您的文本搜索功能。

You said it yourself - you'll be using Lucene one way or the other.

The raw Lucene API isn't very easy to use. It's much more low-level than Hibernate Search. if you're already using Hibernate, then it's a no-brainer - use Hibernate Search to implement your text search functionality.

以可爱出名 2024-11-10 14:50:37

免责声明:我是 Hibernate Search 的开发人员之一。

该项目的目标不是与 Lucene 或 Solr 竞争,而是尽可能促进与 Hibernate 应用程序的集成,以避免必须保持两个世界同步并重复所有映射和 CRUD 操作。

虽然我们提供了一些常见的帮助程序和良好的封装,但 Hibernate Search 还可以为您提供对 Lucene API 的直接引用,因此,如果您发现自己需要使用“原始”Lucene API,您将永远不会陷入困境。另外,对于写入索引,Hibernate Search 提供了一种通用模式,可以解决大多数已知需求,但如果您有非常非标准的需求,您可以完全控制写入的文档。

Solr 是一个不错的选择,但由于它是一个单独的服务器,您必须通过 REST API 与它交互,这是完全不同的,有其优点和缺点。并不总是需要管理第二个服务,当然,远程调用永远不会像直接引用 Lucene 及其所有内部过滤器和缓存那样有效。
并非 Lucene 的所有功能都可以通过远程 API 公开,如果您需要执行一些“低级”操作,如果 Solr 中没有实现,您将无法执行此操作(无需修补 Solr)。尽管如此,Solr 仍然非常可爱,特别是当您想与其他非 Java 应用程序共享索引时,因此我们可能会为 Hibernate 搜索添加一个 Solr 后端,以最终保持 Solr 服务器同步(特别是如果有兴趣的话,并且可能)一些帮助)。

最后,Lucene API 确实是硬核的东西。我们花费了大量的精力来充分利用它来提供顶级性能,同时向使用 Hibernate Search 的人们提供稳定的 API,基本上到目前为止,所有版本都已向后兼容,以提供“直接”性能提升以使用最新版本Lucene 的最大技巧 - 实际上它经常更改 API;这些变化总是令人兴奋,但如果您不使用正确的抽象,请准备好在您的应用程序中维护这些变化。

disclaimer: I'm one of the developers of Hibernate Search.

The goal of the project is not to compete with Lucene nor Solr, but to facilitate as much as possible integration with Hibernate applications, to avoid having to maintain the two worlds in sync and duplicate all mapping and CRUD operations.

While we provide some common helpers and a nice encapsulation, Hibernate Search can also hand you over a direct reference to the Lucene API, so in case you find yourself needing to use the "raw" Lucene API you will never be stuck. Also for writing to the index Hibernate Search provides a common pattern which will solve most of known requirements, but in case you have very non-standard requirements you can get full control of the written Documents.

Solr is a good alternative, but as it is a separate server you have to interact with it via REST APIs which is quite different, with it's pros and cons. Having a second service to manage is not always wanted, and of course the remote invocations will never be as efficient as direct references to Lucene and to all it's internal filters and caches.
Not all functionality of Lucene can be exposed via a remote API, and if you need to do some "low level" operation, if this is not implemented in Solr you won't be able to do it (without patching Solr). Still Solr is very cute, especially when you want to share the index with other non-Java applications, and so we might add a Solr backend for Hibernate Search to eventually keep a Solr server in synch (especially if there's interest for it, and possibly some help).

Finally, the Lucene API is really hard core stuff. We spend a lot of effort to make the best use of it to provide top performance while exposing a stable API to people using Hibernate Search, basically until now all releases have been backwards compatible to provide a "drop-in" performance boost to use latest greatest tricks from Lucene - which actually changes API quite often; these changes are always exciting, but be prepared to maintain that in your application if you don't use a proper abstraction.

凉城 2024-11-10 14:50:37

使用 Lucene 的另一种方法是获取 middlman API,即 SOLR。 SOLR 将连接到 Lucene 并执行 HTTP 调用以进行搜索。请注意,您将需要构建并解析 Solr 使用的 XML。 Lucene 的所有功能都是通过 SOLR 实现的,应该非常有帮助。

The other way of using Lucene is to get the middlman API which is known as SOLR. SOLR will connect to Lucene and perfom HTTP calls for search. Please note that you will need to build and Parse the XML what Solr consumes. All the functionality of Lucene is exponse via SOLR and should be really helpful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文