What does NHibernate.Search ContainedIn attribute do?
-
23-09-2019 - |
Question
And how it differs from IndexedEmbedded?
P.s. and what's the best source of information about NHibernate.Search?
Solution
- Answer
The ContainedInAttribute is used in conjunction with the IndexedEmbeddedAttribute. The ContainedInAttribute is used as a sort of marker, that points back to a class that uses and IndexedEmbeddedAttribute. This tells NHibernate.Search that when you update that class, you want to update the parent's full text index. This is good when you update a child of a owning class and you want the owner's index also updated.
below is an example of how to use this.
[Indexed]
class Parent
{
[IndexedEmbeded]
public Child SomeChild { get; set; }
}
class Child
{
[ContainedIn]
public Parent MyParent { get; set; }
}
Note: The ContainedIn attribute is useless if you are pointing to an owning parent that is not using an IndexEmbeded attribute.
- Answer
Documentation Information is from hibernate search, but most things here apply to NHibernate.Search as well.
http://docs.jboss.org/hibernate/stable/search/reference/en/html/
or
http://docs.jboss.org/hibernate/stable/search/reference/en/html_single/