-->
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.  [ 10 posts ] 
Author Message
 Post subject: Hibernate Search - Sorting of results
PostPosted: Thu Apr 05, 2007 6:10 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
I started to implement a Hibernate / Lucene based solution and would like to switch to Hibernate Search now. It is tempting to only work with Hibernate mapped objects and dropping the low level Lucene Document mapping etc.

However, I have a problem with sorting. I used custom Lucene sorting by passing a Sort instance together with the Lucene Query to the IndexSearcher:

is.search(query, sort);

It seems that with Hibernate Search I can only pass a Lucene query to the FulltextSession:

fullTextSession.createFullTextQuery(query);

How do I do sorting in this case?

If I cannot use Lucene sorting, is there a way to use Hibernate? In HQL I can specify 'order by' clauses. Is there a way an additional 'order by' clause? Currently my search looks like this:

FullTextSession fullTextSession = Search.createFullTextSession(session);
org.hibernate.Query fullTextQuery = fullTextSession.createFullTextQuery(query);
fullTextQuery.list();

What shall I do? Any help appreciated :)

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 5:03 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is not yet possible, but I want to focus on queries for the next release.
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-4

that would be awesome if you had time to contribute this feature :-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 12, 2007 11:39 am 
Regular
Regular

Joined: Wed Apr 25, 2007 10:29 am
Posts: 110
Location: France
Is the order by in Hibernate Search is now supported ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 12, 2007 12:49 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Yes it is :)
Since 3.0.0.beta2. The current release is 3.0.0.beta3.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 3:52 am 
Regular
Regular

Joined: Wed Apr 25, 2007 10:29 am
Posts: 110
Location: France
Thank you, I will try ;)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 5:45 am 
Regular
Regular

Joined: Wed Apr 25, 2007 10:29 am
Posts: 110
Location: France
is it possible to specify ASC ou DESC order ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 7:27 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Sorting is the same as in Lucene.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 8:11 am 
Regular
Regular

Joined: Wed Apr 25, 2007 10:29 am
Posts: 110
Location: France
I use :
Code:
fullTextQuery.setSort(new Sort("fieldname"));

But I don't know how to invert the order of the results.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 3:01 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Use the Sort(String field, boolean reverse) constructor.

Code:
fullTextQuery.setSort(new Sort("fieldname"), true);


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 14, 2007 11:06 am 
Regular
Regular

Joined: Wed Apr 25, 2007 10:29 am
Posts: 110
Location: France
Thank you very much ;)


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