-->
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: Hibernate Search: sorting only the requested page
PostPosted: Tue Aug 02, 2011 11:36 am 
Newbie

Joined: Tue Aug 02, 2011 11:24 am
Posts: 2
Hello,
I've scanned the forum but haven't found anybody having the problem I have.

I am implementing sorting and all works fine except for the fact that the sorting happens before the result page is returned.
In other words, suppose I have 3 pages and I am trying to sort page #1 by person's last name for example. The first page contains names through A to G. When I sort the 1st page as DESC the last names will be from Z to M instead of from G to A.

Here's the code that fetches the page and applies sorting.

Code:
fullTextQuery.setSort(
                new Sort(new SortField (
                                  sortableColumnName, SortField.STRING, isReverseSort))
);

fullTextQuery
  .setFirstResult(paging.getOffset())
  .setMaxResults(paging.getPageSize());

fullTextQuery.list();


is there any way I can make it sort only the results of the requested page?

Would appreciate some hints,

Oleg


Top
 Profile  
 
 Post subject: Re: Hibernate Search: sorting only the requested page
PostPosted: Tue Aug 02, 2011 12:46 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
no, not by the framework; and I don't think it's a problem as everyone would expect it to work like it does :)

You can easily sort the loaded entities yourself after you loaded them by using the Collections API and a custom comparator.

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


Top
 Profile  
 
 Post subject: Re: Hibernate Search: sorting only the requested page
PostPosted: Tue Aug 02, 2011 2:10 pm 
Newbie

Joined: Tue Aug 02, 2011 11:24 am
Posts: 2
=)) Okay... it would just be cleaner without the custom comparators, you know :) And just wanted to make sure I didn't miss a configurable property...

Thanks for the quick response,
Oleg


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.