如何避免使用休眠搜索索引多个等效实体?

发布于 2024-10-01 11:17:38 字数 154 浏览 7 评论 0原文

我正在使用休眠搜索,我想做一些特殊的事情。

在更新人员实体时,保留该实体的方法会复制该实体并创建新的人员实体。 这意味着在更新此人后我将与 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 技术交流群。

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

发布评论

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

评论(1

像你 2024-10-08 11:17:38

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.

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