-->
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: Mixing Lucene FullTextQuery and HQL?
PostPosted: Fri Mar 02, 2007 8:34 am 
Newbie

Joined: Fri Jun 24, 2005 4:36 am
Posts: 14
Location: Germany
Is it possible to mix a Lucene FullTextQuery and HQL?

I need a full text search for product names.
Moreover products are selected by prices, shops etc.

Maybe a kind of FullTextCriteria would be helpful!?

Scenario:
Code:
select * from products where name like '%canon%';

Because LIKE is very slow I use Lucene for full text search.

Next, I select products with a given name and price range.
Code:
select * from products where name like '%canon%' and price between 100 and 200;

Maybe it's not very elegant, but it's possible to manage price ranges with Lucene.

Last, I search products belonging to specific shops:
Code:
select * from products p left join shop s on p.shop_id=s.id
where s.postcode like '2%' and p.name like '%canon%' and p.price between 100 and 200;

This is not possible with a Lucene FullTextQuery. Therefore I want to combine Lucene FullTextQuery with HQL or Criterias.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 02, 2007 12:52 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The main problem is that you need to do that in 2 steps, ie load all the ids from the Lucene query, then apply a HQL query with an additional in restriction.
This does not work well esp if the Lucene query is not discriminative enough.

Your actual scenario should be made possible though.
You should be able to store the shop location informations into the product index (falling back to a single Lucene query)

Today you can solve the issue writing a custom FieldBridge, but I hope to indroduce a more generic solution sometimes in the future.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 07, 2007 7:21 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Your problem is fixed :-)
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-27

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 08, 2007 3:41 am 
Newbie

Joined: Fri Jun 24, 2005 4:36 am
Posts: 14
Location: Germany
Great :-)
Will it ship with the next Hibernate version?
Some more documentation and a demo would be nice...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 08, 2007 7:16 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Yes it will ship with the next version, I still need to refine a couple of things
You mean more doc than what's inside SVN?

_________________
Emmanuel


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.