如何避免使用休眠搜索索引多个等效实体?
我正在使用休眠搜索,我想做一些特殊的事情。
在更新人员实体时,保留该实体的方法会复制该实体并创建新的人员实体。 这意味着在更新此人后我将与 3 人实体站在一起。 (因为我正在对数据库中的所有数据进行版本控制)。
有没有办法避免在休眠搜索索引中对重复元素进行索引?
I'm using hibernate search and I would like to do special things.
On the update of a person entity, the method that persist the entity duplicate this one + create new person entity.
Which means that I'm standing with 3 person entity after an update of this person. (Because I'm versioning all the data in the db).
Is there a way to avoid the indexation of the duplicate element in the hibernate search index?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
hibernate 搜索索引与您的映射紧密配合。如果您通过注释或 xml 文件获得它,那并不重要。您必须通过其中一种方法指定
唯一属性
。我使用 hbm.xml 文件,因此我的配置
unique="true"
。索引是根据您的持久对象进行维护的。您应该安排工作每隔一段时间对其进行优化。
如果你发布了一些你关心的POJO,我可以举个例子更具体一些。
The hibernate search index works closely with your mapping. If you have it via annotations or xml files, it does not matter. You have to specify
unique property
via one of those methods.I use hbm.xml files so my configuration
unique="true"
.The index is maintained based on your persisted objects. You should have scheduled job that optimizes it every once in a while.
If you post some POJO, you are concerned about, I can be more specific with an example.