Hibernate 搜索问题

发布于 2024-08-13 08:26:40 字数 302 浏览 7 评论 0原文

我正在使用 Hibernate Search 并在一个域对象的表上应用 Lucene 索引。我现在想从此表中选择域对象,并根据与其他未索引的表的联接应用过滤。

例如,我有拍卖批次表,我已对其建立了索引。我有报价表。报价引用了拍卖品。

我想在 AuctionLots 表中进行完整的测试搜索并返回没有引号的匹配实体。在普通 SQL 中,这可以通过 JOIN 来实现。

但在使用 HibernateSearch 的情况下,我必须进行完整的测试搜索才能获取域对象,但我不知道如何使用 JOIN 执行过滤。

有谁知道如何做到这一点吗?

I am using Hibernate Search and applied Lucene indexing on one table for a domain object. I want now to make selection from this table for domain objects and apply filtering based on joining with other table, which is not indexed.

For exampple, I have Auction Lots table, which I have indexed. And I have Quotes table. Quotes have references to Auction Lots.

I want to conduct full test search in AuctionLots table and return matched entities which have no quotes. In ordinary SQL this would achieved by JOIN.

But in the situation with HibernateSearch, I have to make full test search in order to obtain domain objects, but I don't know how to perform filtering with JOIN.

Does any body have an idea how to do this?

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

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

发布评论

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

评论(2

夜未央樱花落 2024-08-20 08:26:40

我不建议在为搜索创建索引时进行过滤。据我所知,主要是因为 Hibernate Search 不支持它,而且还因为它没有意义。我认为你应该做的是索引你想要搜索的对象,包括与“子”对象的关系。
我假设您的 ActionLot 对象与您的 Quotes 对象具有一对多关系。使用@IndexEmbedded注释,您可以将报价标记为也应该建立索引的对象。
当您搜索不带引号的 ActionLot 时,您可以在搜索过程中使用搜索查询中的限制或通过对搜索应用全局过滤器来过滤此内容。这可以使用过滤器选项来完成由 Hibernate 搜索提供。

I don't recommend filtering when creating the indexes for your search. Mainly because it is not supported by Hibernate Search as far as I know, but also because it makes no sense. What you should do in my opinion, is index the object you want to search for, including the relations to the 'child' objects.
I assume your ActionLot object has a one-to-many relation to your Quotes objects. With the @IndexEmbedded annotation, you can mark your Quotes as objects which should be indexed as well.
When you search for the ActionLots without quotes, you can filter this during your search using either restrictions in your search query, or by applying a global filter to your search. This can be done using the filter options provided by Hibernate Search.

花想c 2024-08-20 08:26:40

使用 @IndexEmbedded 或 ClassBridge 绝对是正确的方法。更改数据也不应该引起问题。这就是自动索引的用途。您不必在每次报价更改时重新索引所有数据。依靠自动索引将确保只有添加/更新的数据才会被重新索引。
请注意 - 如果您希望在相关报价更改时更新 ActionLot 实例的索引,则需要具有双向关系并使用 @ContainIn

--Hardy

Using @IndexEmbedded or a ClassBridge is definitely the right approach. Also changing data should not cause a problem. That's what automatic indexing is for. You don't have to re-index all the data each time a Quote changes. Relying on auto-indexing will ensure that only the added/updated data gets re-indexed.
As a note - if you want that the index for an ActionLot instance to be updated when the related quote changes, you need to have a bi-directional relationship and use @ConstainedIn

--Hardy

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