-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Searching through multiple types of entities.
PostPosted: Thu Nov 20, 2008 3:55 pm 
Newbie

Joined: Thu Jan 24, 2008 2:06 pm
Posts: 1
Hi,

I have been using Hibernate search for a while now, and I am at a point where I need to implement a global heterogeneous search, where I would enter a query and then would need results from all types of entities on the site.

Do you guys have an idea what is the cleanest way to do this? I dont like the idea of forcing all my @Field annotations to have the same name, and using a MultiFieldQueryParser that contains a superset of all field names will cause maintenance headaches on the long run.

One thought was to create another Parser class that will just look for the field annotations in entities and construct the query using the field names it gleaned.

Another idea would be to add an adapter to each entity that would have the field annotations and delegate to the original entity, would that work? I dont want to save the adapter as an entity in the db so as not to duplicate data, will Hibernate search be able to handle indexing entities that do not exist in the db? how will it retrieve fields from that adapter that are not indexed?

And finally, does either of those ideas sound feasible? is there a better way to do this that I missed? It seems reasonable to assume that a site-wide text search is a common issue, so others must have had the same problem....

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 23, 2008 4:09 am 
Beginner
Beginner

Joined: Thu Jun 21, 2007 1:47 pm
Posts: 46
Using the same name for all your fields should be just fine, even if it seems odd at first.

You can assign multiple names to the same field using @Fields() so that the fields are still specially searchable.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2008 9:40 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
will Hibernate search be able to handle indexing entities that do not exist in the db?

that would be quite hard; you can have different persistence providers, as has been done for the JBoss Cache: http://jbosscache.blogspot.com/2008/07/jboss-cache-searchable.html but I don't think you will go that road.

The SearchFactory of course has a list of all annotated classes, and is holding all information you need to get a list of all declared Field.

I am not seeing particular use for a "search across all", you probably want to list what "all" means, as you may have exceptions one day.

the practice recommended by dobes looks like the best option IMHO, so you still can list classes to include or exclude dynamically.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.