-->
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.  [ 4 posts ] 
Author Message
 Post subject: Query to return all entity associated with a class
PostPosted: Fri Oct 09, 2009 3:17 pm 
Newbie

Joined: Tue Jul 22, 2008 11:30 am
Posts: 13
Hi,

I have a view in my application that shows a list of Foo items in my system. That list will get filtered based on what the user types into a search box. Searching and filtering based on attributes works great and was a breeze to configure. What i'm having trouble with is coming up with a query to show me all my items.

Code:
  MultiFieldQueryParser parser = new MultiFieldQueryParser(defaultNames, new StandardAnalyzer());
  org.apache.lucene.search.Query luceneQuery = luceneQuery = parser.parse(search);
  FullTextEntityManager fullTextEntityManager = Search.createFullTextEntityManager(em);
  FullTextQuery searchCriteria = fullTextEntityManager.createFullTextQuery(luceneQuery, Foo.class);


I guess i was hoping to give search a value of * which would then return everything in the index that is a Foo.class Is there a way to do this in Hibernate Search? I guess as a back up i could just query against the database, but i'm not too excited with the idea of maintaing my hibernateSearch - search code as well as the typical hibernate HQL query portion of it if/when tables/columns/etc changes.

Thoughts?
Thanks,


Top
 Profile  
 
 Post subject: Re: Query to return all entity associated with a class
PostPosted: Sat Oct 10, 2009 12:00 pm 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
I guess one way would be to do the following query:

Code:
_hibernate_class:com.Foo


That lucene query would return all of the results that were matched. I just gave it a go and it works. You would need to ensure that the field _hibernate_class was present in the search fields.

Hope that helps


Top
 Profile  
 
 Post subject: Re: Query to return all entity associated with a class
PostPosted: Sun Oct 11, 2009 6:34 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
You can match all by using a MatchAllDocsQuery, no need to create a QueryParser.

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


Top
 Profile  
 
 Post subject: Re: Query to return all entity associated with a class
PostPosted: Sun Oct 11, 2009 9:59 pm 
Newbie

Joined: Tue Jul 22, 2008 11:30 am
Posts: 13
The matchAllDocuments query worked great! Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.