开发者

Index Multiple Entities using Hibernate Search

开发者 https://www.devze.com 2023-04-06 01:31 出处:网络
Is it possible to Index multiple entities within same index using Hibernate Search ? I have 3 entities User, Category and Campaign. These entities are not related to each other.

Is it possible to Index multiple entities within same index using Hibernate Search ? I have 3 entities User, Category and Campaign. These entities are not related to each other.

I need to provide a functionality where user can search across these entities. Similar to facebook search or Quora search.

Eg: https://www.facebook.com/search.php?q=Stackoverflow will show all t开发者_C百科he groups, pages etc with the given query string.


I do realize that this is a rather old question, but I'll still post an answer to this question as it might some day still help someone.

Yes, it is possible. How you can do that is described here: http://docs.jboss.org/hibernate/search/4.2/reference/en-US/html_single/#section-sharing-indexes


It's not possible (AFAIK) to index multiple entities within the same index, though you can query multiple indexes at the same time using the FullTextSession.createFullTextQuery(Query, Class<?> ...) method. In your case, the usage would be fullTextSession.createFullTextQuery(query, User.class, Category.class, Campaign.class);.

0

精彩评论

暂无评论...
验证码 换一张
取 消