-->
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.  [ 4 posts ] 
Author Message
 Post subject: Is it possible to filter Objects and not the fields?
PostPosted: Sun Jul 04, 2010 3:28 am 
Beginner
Beginner

Joined: Thu Jun 24, 2010 2:30 am
Posts: 23
In examples of Analizers that I saw, filters change search results for index of one specific fields. I haven't seen filter that do following: check whether field matches some conditions and if not, extracts the whole object found from search result. I have such task: search should return only objects that current user is authorized to see. I can do it with loop on search results before I return it, but it will be more natural if it just will not returned from search. Can somebody explain to me if it is possible and if true, how to do it.


Top
 Profile  
 
 Post subject: Re: Is it possible to filter Objects and not the fields?
PostPosted: Mon Jul 05, 2010 4:48 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

I think your are mixing up two orthogonal concepts here - projections and filtering. Projection is the idea of skipping the round trip to the database and return data directly from the Lucene index. The advantage being speed, the disadvantage being that you are working with object arrays instead of managed objects.
The concept of filtering comes from the Lucene world and allows to "narrow down" the results of a raw search by applying a chain of filters. Since this is a Lucene feature you have to filter on Field values, but that does not mean that you cannot have Hibernate managed entities as result of your search. If you want to implement a security filter just index the property you need for authorization and filter on it.
Btw, Analyzers are yet another concept.
I recommend you look up these three concepts in the Hibernate Search Online documentation. I think it even has an example for a security filter.

--Hardy


Top
 Profile  
 
 Post subject: Re: Is it possible to filter Objects and not the fields?
PostPosted: Mon Jul 05, 2010 10:57 am 
Beginner
Beginner

Joined: Thu Jun 24, 2010 2:30 am
Posts: 23
Thanks. I thought that filters defined only as part of analizer, but I see that I was wrong. Now, I understand that I need filter, but it creates other question. The example of security filter in documentation checks in index whether level==5. It means that there is field indexed with "level" in every object that can be result of query the filter applied to. Imagine, I have classes A and B, the filter should be applied to and base class C, these objects inherite from. Class C has "level" field. Will the filter work, or it will complain that query results don't contain "level" field?


Top
 Profile  
 
 Post subject: Re: Is it possible to filter Objects and not the fields?
PostPosted: Mon Jul 05, 2010 11:01 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Provided level is annotated with @Field it should work. Base class properties can be indexed as well. Just annotate them accordingly.

--Hardy


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