-->
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: Hyrid query and paging (Hibernate Search + standard query)
PostPosted: Wed Apr 23, 2008 11:22 pm 
Newbie

Joined: Wed Apr 23, 2008 11:11 pm
Posts: 19
Hi,

We are using hibernate search in an hybrid mode, that is we have an object with the lucene query and a criteria that we use in our persistence service. Internally, the service performs a search on lucene and on the db and performs an intersect (that is returns result that matches both the hibernate and the lucene query).

We must support paging as it is a core functionality of our app and I'm wondering how we can do this efficiently. I am wondering if the way hibernate does its paging is described somewhere so that we can have a look to understand how it works.

Can anyone advice about this use case and whether a better technical choice can be used. In particular, is it a good idea to mix a lucene query and an hibernate search? So far it's not really performant and we're searching ways to improve the situation.

Thx.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 24, 2008 3:19 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
this post is about the same problem:
http://forum.hibernate.org/viewtopic.php?t=986012

So it is not possible ( in an efficient way);
We had the same problem and solved it in a quite satisfying way adding some extra fields to the Lucene index, so that you can use standard HQL when no free-text has been selected, or use a Lucene query for all fields when a mixed input has been selected.

An example input form to search a user: a combobox "nationality", a free-text "name":
A)when only "nationality" is filled in, we search by HQL using nation-id
B)when the "name" is filled in, we search by Lucene
C)when both are filled in, we also search by Lucene, having the nationality-id encoded as a field in the Lucene documents.

The intersection solution could work fine if you may force your user to only see the first page, and then have to scroll by using a "next" button;
Unfortunately you usually want to show a "total count" and provide a "page20" button...

If you really want to go on with the "intersection solution" I would suggest you to fetch from DB only the primary keys, using a scrollable result and adding them all to a set;

Some DBMS integrate a full-text "plugin" so you can mix the full-text query with SQL, but performance is horrible as they suffer from the same problem.

Quote:
I am wondering if the way hibernate does its paging is described somewhere so that we can have a look to understand how it works

It depends on the DB.. easiest way is to enable SQL logging so you can see what it does.

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


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 4:56 am 
Newbie

Joined: Wed Apr 30, 2008 12:10 pm
Posts: 6
Hi,

I do think it is possible to do a criteria search in a fulltextquery BUTT only for simple criteria searches. E.g. House.price

crit.add(Restrictions.in("price", price ));

fullTextSession.createFullTextQuery( bq, House.class)
.setCriteriaQuery(crit);

This works for me. Unfortunatly I need a bit more comprehensive search (collection) and this seems impossible.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 02, 2008 6:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
ghvandoorn wrote:
Hi,

I do think it is possible to do a criteria search in a fulltextquery BUTT only for simple criteria searches. E.g. House.price

crit.add(Restrictions.in("price", price ));

fullTextSession.createFullTextQuery( bq, House.class)
.setCriteriaQuery(crit);

This works for me. Unfortunatly I need a bit more comprehensive search (collection) and this seems impossible.


What's your pagination algorithm? How much useless Documents do you have to load in memory?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 02, 2008 6:08 pm 
Newbie

Joined: Wed Apr 30, 2008 12:10 pm
Posts: 6
I'm wasn't saying that I'm using that (criteria search)....


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.