我已通过以下来源的教程将 NHibernate.Search 集成到我的网络应用程序中:
我还成功地对我的数据库进行了批量索引,并且在针对 Luke 进行测试时,我可以搜索驻留在我标记为可索引的任何实体中的术语。
但是,当我尝试通过我的网络应用程序更新多对多实体时,我的父索引似乎没有更新。例如:
public class Books
{
HasAndBelongsToMany(typeof(Author), Table = "BookAuthor", ColumnKey = "BookId", ColumnRef = "AuthorId")]
[IndexedEmbedded]
public IList<Author> Authors
{
get { return authors; }
set { authors = value; }
}
}
public class Author
{
HasAndBelongsToMany(typeof(Book), Table = "BookAuthor", ColumnKey = "AuthorId", ColumnRef = "BookId"), Inverse=true]
[ContainedIn]
public IList<Author> Authors
{
get { return authors; }
set { authors = value; }
}
}
现在,当我尝试执行类似的操作时,myBook.Authors.Add(Author.Create("xxx"))
我可以看到我的作者索引已更新,但是,图书索引(即父索引)尚未更新,并且搜索新添加的作者返回一个空结果。
请注意,这只发生在处理多对多关系时。
我不确定为什么会这样。有没有其他人遇到过类似的困难?如果我能指出正确的方向,我将不胜感激,干杯。