-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problems with Hibernate Search
PostPosted: Tue Feb 03, 2015 3:23 pm 
Newbie

Joined: Thu Apr 07, 2005 8:58 am
Posts: 6
I am using OGM with a mongoDB database andtried to get Hibernate Search to work. When trying out the given example (see below) on my database I get an error:
OGM-23 - Criteria queries are not supported yet
Am I doing something wrong?
Can someone give me a working example?

******************************************************

Example (slightly adjusted) from http://hibernate.org/search/documentation/getting-started/

QueryBuilder qb = fullTextEntityManager.getSearchFactory()
.buildQueryBuilder().forEntity(Docu.class).get();
org.apache.lucene.search.Query luceneQuery = qb
.keyword()
.onFields("body")
.matching("curator")
.createQuery();

// wrap Lucene query in a javax.persistence.Query
javax.persistence.Query jpaQuery =
fullTextEntityManager.createFullTextQuery(luceneQuery, Docu.class);

// execute search
List result = jpaQuery.getResultList();


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate Search
PostPosted: Wed Feb 04, 2015 3:55 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi,

Hibernate OGM does not implement the Criteria API at this point. Therefore you need to configure a specific database retrieval method for full text queries which internally does not depend on the Criteria API. The following does the trick:

Code:
FullTextQuery ftq = fullTextEntityManager.createFullTextQuery(luceneQuery, Docu.class);
ftq.initializeObjectsWith(ObjectLookupMethod.SKIP, DatabaseRetrievalMethod.FIND_BY_ID);


Alternatively you can configure this globally when bootstrapping Hibernate OGM by setting the following properties in your persistence.xml (or map used for bootstrapping the entity manager factory):

Code:
hibernate.search.query.object_lookup_method = skip
hibernate.search.query.database_retrieval_method = find_by_id


This step will eventually be automated in Hibernate OGM (see https://hibernate.atlassian.net/browse/OGM-171), but we didn't get to this yet.

Hth,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate Search
PostPosted: Thu Feb 05, 2015 1:12 pm 
Newbie

Joined: Thu Apr 07, 2005 8:58 am
Posts: 6
That makes sense.

However, how do it get a result set from the FullTextQuery object?
The fullTestSession does not seem to have a method that takes a FullTextQuery object but only a Query object:

fullTextSession.createFullTextQuery(ftq, Docu.class) -> ???


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate Search
PostPosted: Fri Feb 06, 2015 3:55 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
org.hibernate.search.FullTextQuery e.g. offers list() and uniqueResult(), whereas on org.hibernate.search.jpa.FullTextQuery you have getResultList(), getSingleResult() etc.

The reference guide has a complete example here: https://docs.jboss.org/hibernate/ogm/4.1/reference/en-US/html_single/#_using_hibernate_search

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate Search
PostPosted: Mon Feb 09, 2015 3:32 pm 
Newbie

Joined: Thu Apr 07, 2005 8:58 am
Posts: 6
Thank you. I did not see the Query object in the correct package...


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