没有数据库的休眠搜索

发布于 2024-10-21 04:15:31 字数 395 浏览 6 评论 0原文

是否可以仅将 hibernate-search 用于其注释(bean => document/document => bean 映射),而不使用数据库?如果是这样,是否有任何在线示例基本上显示如何进行设置?

我发现以下内容: http: //mojodna.net/2006/10/02/searchable-annotation-driven-indexing-and-searching-with-lucene.html,但如果它支持我的用例,我更喜欢 hibernate-search。

Is it possible to use hibernate-search only for it's annotations (bean => document/document => bean mapping), without using a database at all? If so, are there any online samples that show basically how to set this up?

I found the following: http://mojodna.net/2006/10/02/searchable-annotation-driven-indexing-and-searching-with-lucene.html, but I'd prefer hibernate-search if it supports my use case.

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

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

发布评论

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

评论(3

作妖 2024-10-28 04:15:31

Hibernate search 3.4 已将查询引擎与 Hibernate Core 解耦。例如,Hibernate Search 被重用来通过 Infinispan 实现查询。我不知道代码是否已打包,以便您可以将 HS 与 Spring 和 JDBCTemplate 一起使用(我想做的事情)。这是我稍后会调查的线索,但也许你可以检查一下......

Hibernate search 3.4 has decoupled the query engine from Hibernate Core. For instance, Hibernate Search is reused to implement queries with Infinispan. I don't know if the code is packaged so that you could use HS with, let's say Spring and JDBCTemplate (something I would like to do). That's a lead I will investigate later but maybe you can check it out...

当爱已成负担 2024-10-28 04:15:31

Starman 是正确的,3.4 版中的 Hibernate Search 正在从 Hibernate Core 中抽象出搜索引擎,而 Infinispan Query 是一个集成示例,无需数据库即可正常工作。 Spring 也不会有问题,但您需要确保将更新事件发送到查询引擎,以便索引不会不同步。使用 Hibernate 的优点是,它透明地侦听对数据库的更改,并在事务提交时将它们应用到索引,因此索引始终保持同步(或关闭,如果将搜索配置为使用异步后端)。

我建议查看 Infinispan Query 的代码,因为它非常小,并且只是委托调用来公开 Infinispan 风格的 API。大多数代码都是测试或集成,以正确管理引擎的生命周期:与 Infinispan 一起启动和停止它。

Starman is correct, Hibernate Search in version 3.4 is abstracting the search engine from Hibernate Core, and the Infinispan Query is an integration example which works fine without a database. There would be no problems with Spring either, but you'd need to make sure to send update event to the query engine so that the index doesn't get out of synch. When using Hibernate the advantage is that it transparently listens for changes to the database and applies them to the index at transaction commit, so the index is always in synch (or close, if configuring Search to use async backends).

I'd suggest to look into the code of Infinispan Query, as it's very small and just delegating calls to expose an Infinispan flavoured API. Most of the code is tests or integration to properly manage the lifecycle of the engine: start and stop it together with Infinispan.

如日中天 2024-10-28 04:15:31

我认为这是不可能的,因为当您启用 Hibernate 搜索时,您是在实体上启用该搜索,并且该实体具有对表和搜索索引的引用。

I don't think that's possible because when you enable Hibernate search you are enabling that on a Entity and that Entity has references to the table and the search index.

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