-->
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: HIBERNATE SEARCH Filters
PostPosted: Fri Nov 21, 2008 3:49 pm 
Beginner
Beginner

Joined: Tue Feb 12, 2008 3:53 pm
Posts: 38
Hi,

I am implementing a full text research with HIBERNATE SEARCH.

I want to make a full text research on the "value" property of my object Itemdata

Code:
@Indexed
public class ItemData  {
   /**
    * Item Data Id
    */
        @DocumentId
   protected long itemDataId;
   /**
    * Item data value
    * The data collected for an item. This data is represented according to DataType
    * attribute of the Item.
    */
        @Field
   protected String value;
   /**
    *

.........
}


When I am going to run the search I will get a list of results

Code:
         
     List<Itemdata> results = hibQuery.list();


Among this list I want to keep only the Itemdatas that are accessible to the connected user.
In my database, it corresponds to the following request :

Code:
select idat.*
from itemdata idat, itemgroupdata igdat, formdata fdat, eventdata edat, subject sbj, sites si, study s,groups grp, groups_users grpu, user usr
where idat1.ITEM_GROUP_DATA_ID=igdat.ITEM_GROUP_DATA_ID
and igdat.FORM_DATA_ID=fdat.FORM_DATA_ID
and fdat.EVENT_DATA_ID=edat.EVENT_DATA_ID
and edat.SUBJECT_ID=sbj.SUBJECT_ID
and sbj.SITE_ID=si.SITE_ID
and sbj.PROJECT_ID=s.PROJECT_ID
and s.study_id=grp.study_id
and grp.group_id=grpu.group_id
and grpu.user_id=usr_id
and usr.site_id=sbj.site_id
and usr.user_id=234;


As you can see the request is very complexe.
If I want to build a HIBERNATE SEARCH Filter on top of my HIBERNATE SEARCH query, to obtain this restriction, I don't know how to implement it.
According to what I read, Filters on HIBERNATE SEARCH can be implemented from several properties that are indexed by HIBERNATE SEARCH.
For example select the cars which color is blue, or select a car that is owned by a man living in los Angeles.
But in my case to implement a filter would suppose that I indexe the whole relation between an Itemdata and a user. It's impossible.
Has anyone an idea how I can build a such Filter ?

The best solution might be to Collect all the Itemdata accessible to the user by a database request and then make an intersection with my HIBERNATE SEARCH result

Can anyone help me ? Thank you in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2008 8:50 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
But in my case to implement a filter would suppose that I indexe the whole relation between an Itemdata and a user. It's impossible.

Why would that be impossible? looking at your hql query it is looking quite easy to do.

The alternative would be to implement a DocIdSet iterator, you would need to use the latest 3.1.0CR1 for that. But this is quite more advanced and I'd suggest to use the easy way, by mapping the relation from ItemData and user to the index.

Do you need more help on this? Basically you map the relation graph to appropriate keys in the index. The result is also much more efficient than using the iteration, I suspect it would be quite slow in your case.

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


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.