使用 NHibernate.Search 处理多对多关系时,Lucene.NET 索引不会更新
我已按照以下来源的教程将 NHibernate.Search 集成到我的 Web 应用程序中:
我还成功地对我的数据库进行了批量索引,并且在针对 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"))
之类的操作时,我可以看到我的作者索引已更新,但是图书索引(这是父索引)尚未更新,搜索新添加的作者将返回空结果。
请注意,这只在处理多对多关系时才会发生。
我不知道为什么会这样。还有其他人遇到过类似的困难吗?如果我能指出正确的方向,我将不胜感激,干杯。
I have integrated NHibernate.Search into my web app by following tutorials from the following sources:
- NHibernate.Search using Lucene.NET Full Text Index (Part 1)
- Using NHibernate.Search with ActiveRecord
I have also successfully batch-indexed my database, and when testing against Luke, I can search for terms that reside in whatever entities I marked as indexable.
However, when I attempt to update many-to-many entities via my web app, my parent index does not seem to update. For example:
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; }
}
}
Now, when I try to do things like myBook.Authors.Add(Author.Create("xxx"))
I can see that my Author index has been updated, however, the Book index (which is the parent index) has not been updated and searching for the newly added author returns an empty result.
Note that this only happens when dealing with many-to-many relationships.
I am not sure why this is so. Has anyone else experienced similar difficulties? I'd appreciate it if I could be pointed in the right direction, cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近更新了 NHibernate Search 的主干来解决这个问题。您将必须下载并编译最新的代码,并使用适当的侦听器修改您的配置,以便传播集合更改...
I've recently updated the trunk of NHibernate Search to fix this issue. You will have to download and compile the latest code and modify your config with the appropriate listeners for the collection changes to propogate...