-->
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.  [ 2 posts ] 
Author Message
 Post subject: getting empty list from full text query
PostPosted: Wed Dec 31, 2008 4:53 pm 
Newbie

Joined: Wed Dec 31, 2008 4:13 pm
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp


I have the following code snippet where in some cases the call to ftQuery.getResultSize() returns > 0 but the ftQuery.list() actually returns an empty list. I have several test cases and only in some cases does this situation arise. This seems similar to the issue in post (http://forum.hibernate.org/viewtopic.php?t=980700).


Code:
            // wrap Lucene query in a org.hibernate.Query
            FullTextQuery ftQuery = fullTextSession.createFullTextQuery(query, returnTypes);
           
            // Log the query we are using
            logQuery(ftQuery);

            // execute search
            retObj = ftQuery.list();

            logger.debug("### results size: " + ftQuery.getResultSize() + ", results: " + retObj);


when I output the actual query hibernate is running and run it in TOAD the query works fine given the values from the ID field. I ran the lucene query in Luke and the number of results matches the ones from the sysout above.

I should mention that on my entity the ID is a composite class.

Here is the FieldBridge I wrote for the composite key.
Code:
public class SearchTermsViewIdFieldBridge implements TwoWayStringBridge {
   
   @Override
   public String objectToString(Object arg0) {
      
      String retString = null;
      
      if (arg0 instanceof SearchTermsViewId) {
         SearchTermsViewId id = (SearchTermsViewId)arg0;
         StringBuilder sb = new StringBuilder();
         retString = sb.append(id.getSearchRef()).append("_")
                     .append(id.getSearchRefId()).append("_")
                     .append(id.getXSearchTermId())
                     .toString();
      }
      
      return retString;
   }

   @Override
   public Object stringToObject(String arg0) {
      
      String[] fields = arg0.split("_");
      
      SearchTermsViewId id = new SearchTermsViewId();
      id.setSearchRef(fields[0]);
      id.setSearchRefId(fields[1]);
      id.setXSearchTermId(fields[2]);
      
      return id;
   }


For example, the following 2 lucene queries get hits, but the ftQuery.list() returns an empty list:

Quote:
example 1: searchTerm.searchTermString:steak*
example 2: searchTerm.searchTermString:italian*

however, the following lucene query gets hits and ftQuery.list() returns correct number of ojbects:
Quote:
+searchTerm.searchTermString:steak* +searchTerm.searchTermString:angus*


I'm using Hibernate version: 3.3.0 and Hibernate Search: 3.1.0.GA and Spring 2.5

Any suggestions?


Top
 Profile  
 
 Post subject: getting empty list from full text query.. more info
PostPosted: Thu Jan 01, 2009 12:16 am 
Newbie

Joined: Wed Dec 31, 2008 4:13 pm
Posts: 3
i traced thru the Hibernate Search classes and found the following:

the ObjectLoaderHelper.initializeObjects method makes these 2 calls and the Criteria.list is returning an empty list even though the disjunction contains valid ids and they are in the correct order.

Code:
criteria.add( disjunction );
criteria.list(); //load all objects


i printed the idName and ids that are passed to the
Code:
disjunction.add( Restrictions.in( idName, ids ) );


when the following are used, the criteria.list creates an empty list
idName:id, ids: [1006 EVENT 1008, 1006 FACILITY 1014, 1063 EVENT 1008, 1063 FACILITY 1014, 1305 FACILITY 1014, 1305 EVENT 1008]

when the following ids are used the criteria.list returns expected results
idName:id, ids: [1182 FACILITY 1003]


are there known issues with composites IDs and using the disjunction class?


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