-->
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.  [ 1 post ] 
Author Message
 Post subject: Sorting
PostPosted: Wed Apr 17, 2013 9:28 pm 
Newbie

Joined: Fri Apr 05, 2013 3:28 pm
Posts: 9
I have the following query set up and it is working. However, I cannot get the sort to work. I have basic questions, such as, should I be able to sort across all classes such that I truly see output in title order? I want to order by title first, not title within bestPractices and title within caseSummaries.
Code:
private static List<KnowledgeArticle> searchKnowledgeArticles(String queryString) {       
      Session session = HibernateUtil.getSession();       
      FullTextSession fullTextSession = Search.getFullTextSession(session);                 
      QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(KnowledgeArticle.class).get();       
      org.apache.lucene.search.Query luceneQuery = queryBuilder.keyword()
            .fuzzy()
            .withThreshold( .8f )
            .withPrefixLength( 1 )
.onFields("articleNumber","bestPractices.title","caseSummaries.title","bestPractices.summary","caseSummaries.summary","caseSummaries.resolution","bestPractices.bestPractice").matching(queryString).createQuery();
      
   
      // wrap Lucene query in a javax.persistence.Query       
      org.hibernate.search.FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery, KnowledgeArticle.class, BestPractice.class, CaseSummary.class);                 
/*   org.apache.lucene.search.Sort sort = new Sort(
             new SortField("bestPractices.title", SortField.STRING));
         fullTextQuery.setSort(sort);*/


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

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.