-->
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.  [ 6 posts ] 
Author Message
 Post subject: [Hibernate Search] Query for retrieving all records ?
PostPosted: Sat Jul 07, 2007 5:52 am 
Regular
Regular

Joined: Tue Nov 04, 2003 12:37 pm
Posts: 57
Hello,

How can I define a FullTextQuery to retrieve all the records ?

Best regards,
Eric


Top
 Profile  
 
 Post subject: ...
PostPosted: Sat Jul 07, 2007 5:13 pm 
Newbie

Joined: Fri Jul 06, 2007 5:45 pm
Posts: 5
I'm not excactly sure what you mean by "retrieve all records" since from what I understand a simple query.list() will return all the records that matched your fulltext query.

Being a newbie too, I guess you're having the same problem I had a couple of days ago: query multiple fields. I haven't yet found a way to query *all* possible fields, but MultiFieldQueryParser at least allows you to specify an array of fields you want to include.

Hope this helps.

Fr.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 09, 2007 3:22 am 
Newbie

Joined: Fri Jun 29, 2007 5:01 am
Posts: 12
Hi,

if you want to retrieve all records for an indexed class (without any query restrictions) the FullTextQuery would look like this:


// the field _hibernate_class stores the class name
QueryParser luceneParser =
new QueryParser("_hibernate_class", new KeywordAnalyzer());

//clazz is the class for which you want to retrieve all records for
Query luceneQuery = luceneParser.parse(clazz.getName());

//limit results to the given class: clazz
FullTextQuery query = fullTextSession.createFullTextQuery(luceneQuery, clazz);


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 11, 2007 1:50 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
but a this point a simple HQL query will be more efficient

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 16, 2007 2:33 am 
Newbie

Joined: Fri Jun 29, 2007 5:01 am
Posts: 12
Jo, thats true. But HQL would retrieve real objects from the database. the index search lets you use projection (if applicable) and results in a much faster responce. I have 50,000 datasets and use descriptor objects to display them in a list. Hibernate Search with projection is a lot faster than the HQL query...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 17, 2007 3:17 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I beg to differ, there is no reason why a paginated SQL query would be slower that a paginated Lucene query if the query is nothing more that retrieving everything.

_________________
Emmanuel


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