-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Search: parent index updated when child changes?
PostPosted: Sat Apr 19, 2008 1:53 am 
Newbie

Joined: Thu Oct 18, 2007 5:27 pm
Posts: 4
The scenario:
Person has a OneToOne relationship with Address. The Person is indexed and searches work great when searching for a Person on fields contained in the Person or the Address (person.firstName, address.zipCode, etc all work fine). Now, say the Address zipCode gets updated without going through the Person, yet still within the Hibernate Search environment (some generic Address editor modifies the Address without touching the Person).

The question:
Should searching for a Person on the address.zipCode field return the new value of address.zipCode or the old one that the Person saw when it was first indexed?

From what I can tell, the Person doesn't see the new value of zipCode in any searches until the Person itself gets manually reindexed or a field on the Person changes and is persisted. Looking at the Address index, it has been updated with the new zipCode value.

Even if the object model does not reflect the child to parent relationship (the Java Address object has no idea what it is attached to), it would seem that the Lucene index could still be updated with the new information especially if Store.NO is selected for all of the fields.

What is the intended behavior? Am I missing something, is there a workaround, or a best practice?

Please let me know if what I have described above is unclear and I'd be happy to give additional details.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 19, 2008 5:21 am 
Hibernate Team
Hibernate Team

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

Have you read the online documentation regarding 'Embedded and associated objects' - http://www.hibernate.org/hib_docs/search/reference/en/html_single/#d0e1236? You'll have to make your relationshio bi-directional and use @ContainedIn.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 19, 2008 9:48 am 
Newbie

Joined: Thu Oct 18, 2007 5:27 pm
Posts: 4
I did run across that, but was hoping there was a way to kick off the indexing without having to reflect the relationship in the object model. Having to reflect the child to parent relationships can get messy if there are several types of objects that attach to that type of child. For instance, Company gets attached to Address, Person gets attached to Address, etc and now there are several collections hanging around in Address that make the object model non-ideal.

It would seem possible to at most use the @ContainedIn annotation in the Address and not need the actual collections. This would look like:
@ContainedIn(Person,Company) or something.

Just curious if this is possible now, in the future, or doesn't make sense.

Thanks for the response thus far!


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