-->
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.  [ 6 posts ] 
Author Message
 Post subject: Exclude logically deleted entities from search
PostPosted: Wed Apr 07, 2010 8:28 am 
Newbie

Joined: Tue Dec 26, 2006 1:36 pm
Posts: 4
Hi,

In our system, we use logical deletion (although manually, not using @SqlDelete). I found that I can easily exclude deleted entities from the search results using a Filter on the @Indexed class. However, we have a slightly different case.

Let's say we have an @Indexed Partner entity, which has associated Addresses (@IndexEmbedded), and address entities have a String location field (nb: this is not the real case, just a simple example). For some reason, I can delete Address entities only logically, that is by setting a deleted flag to true. In this scenario, I want to search for partners by entering a location, and I want to have all partners in the result list which has a location that matches what I entered. This is easily achieved by using @Index on Partner, @IndexEmbedded on Partner.addresses, and @Field on Address.location, and searching for "addresses.location" fields. But this will match deleted locations as well.

I cannot figure out how to exclude logically deleted locations from my search.

Well, the only "solution" I can see for now is to implement special bridges for the Address entity that "hides" all of its property values from lucene when the entity is marked as deleted.

Thanks in advance


Top
 Profile  
 
 Post subject: Re: Exclude logically deleted entities from search
PostPosted: Wed Apr 07, 2010 1:18 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
you could target the Address for queries making them @Indexed too and adding a "deleted=false" clause the the query, then getting the Partner from the relation.

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


Top
 Profile  
 
 Post subject: Re: Exclude logically deleted entities from search
PostPosted: Thu Apr 08, 2010 4:18 am 
Newbie

Joined: Thu Apr 01, 2010 9:47 am
Posts: 6
This happens because the flattened nature of the Lucene index.
When you use @IndexedEmbedded, all embedded fields are thrown together as part of the embedding object, as a result the information of which embedded fields 'belong together' is lost and you cannot do such queries via the embedding object.

E.g. : a partner could have the following Document entry in the index:

id
adresses.location
adresses.location
addresses.deleted < To which of the 'location' fields do the 'deleted' fields belong? No way to tell because this information isn't there.
addresses.deleted <

Another possible solution would be to cut the Partner-Address link when you do a logical deletion. The Partner will then be reindexed without the 'deleted' Address.


Top
 Profile  
 
 Post subject: Re: Exclude logically deleted entities from search
PostPosted: Thu Apr 08, 2010 4:28 am 
Newbie

Joined: Tue Dec 26, 2006 1:36 pm
Posts: 4
Sanne: that's possible in the example above, but unfortunately the real entity structure is much more complex.

Removing them from the relation sounds feasible (and useful anyway), I'll try that, thanks for your replies.

Gabor


Top
 Profile  
 
 Post subject: Re: Exclude logically deleted entities from search
PostPosted: Thu Apr 08, 2010 4:44 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
Another possible solution would be to cut the Partner-Address link when you do a logical deletion. The Partner will then be reindexed without the 'deleted' Address.

cool, seems a clever solution.

Gabor, let us know how it goes.

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


Top
 Profile  
 
 Post subject: Re: Exclude logically deleted entities from search
PostPosted: Wed Apr 28, 2010 5:20 am 
Newbie

Joined: Tue Dec 26, 2006 1:36 pm
Posts: 4
Hi, sorry for the late reply, I've been busy doing some other stuff.

So, removing the deleted item from the containing collection explicitly solved the issue.

(Nb, i'm still using 3.1.1GA, so due to http://opensource.atlassian.com/project ... SEARCH-391 I reindex the root entity after the removal. I guess in 3.1.2 this kind deletion works at deeper levels as well).

Thank you for your answers!


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