如何将 Hibernate 和 Solr 集成在一起? [英] How to integrate Hibernate and Solr together?

查看:26
本文介绍了如何将 Hibernate 和 Solr 集成在一起?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于使用 Hibernate 管理对象持久性的人来说,Hibernate 搜索是一个真正的救星.
在尝试开发类似的功能(收集所有对象更改并在事务提交时将它们发送到全文搜索引擎)之后,您很快就会发现存在很多陷阱.
另一方面,Solr 有其自身的优势(例如 1:m 方面,如果您需要的话),这使其成为某些情况下的合适决定.
因此,如果我使用 Hibernate 作为 JPA 提供者并在 Solr 上索引我的对象,那么如何将这些组件集成在一起?

For people working with Hibernate to manage their objects persistence, Hibernate search is a real savior.
After trying to develop similar functionality (collecting all objects changes and sending them to a full text search engine upon transaction commit) you find out pretty fast that there are lots of pitfalls out there.
On the other hand Solr has its own advantages (like 1:m facets for example if you need it) which make it a suitable decision on some scenarios.
So if I work with Hibernate as the JPA provider and index my objects on Solr, how can these components be integrated together?

推荐答案

如果你想同时使用它们是可能的,尽管这需要一些编程工作.
这个想法是与 Hibernate Search 一起完成所有艰苦的工作,然后收集对象的更改并将它们转发到 Solr.
这可以通过配置 Hibernate Search 以使用 JMS 或通过实现 BackendQueueProcessor 类并将其注册为休眠搜索处理器来完成.
如果您想查看工作示例,请查看 hibernate_search_solr_integration.
请记住,这只是一个概念演示,您可能需要处理很多问题,例如连接失败、同步问题、线程并发、软提交优化等...

In case you want to use them both together is turns out it is possible although it will require some programming work.
The idea is to work with Hibernate Search to do all the hard work and then collect the objects's changes and forward them to Solr.
This can be done either by configuring Hibernate Search to work with JMS or by implementing the BackendQueueProcessor class and registering it as the hibernate search processor.
If you wish to check out a working example, check out hibernate_search_solr_integration.
Just remember that it's just a concept demonstration and you will probably need to handle lots of issues such as connectivity failure, sync problems, thread concurrency, soft commit optimizations, etc...

这篇关于如何将 Hibernate 和 Solr 集成在一起?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆