当使用NHibernate.Search许多一对多的关系,处理Lucene.NET索引不更新 [英] Lucene.NET indexes are not updating when dealing with many-to-many relationships using NHibernate.Search

查看:167
本文介绍了当使用NHibernate.Search许多一对多的关系,处理Lucene.NET索引不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从下列来源整合NHibernate.Search到我的web应用程序通过以下教程:

I have integrated NHibernate.Search into my web app by following tutorials from the following sources:

  • <一个href="http://blogs.intesoft.net/post/2008/03/NHibernateSearch-using-Lucene-NET-Full-Text-Index-Part1.aspx"相对=nofollow>使用Lucene.NET全文索引(第一部分)
  • 使用NHibernate.Search用ActiveRecord
  • 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.

然而,当我试图通过我的web应用程序更新许多到许多实体,我的父母指数似乎并没有更新。例如:

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; }
     }
}

现在,当我尝试做的事情一样 myBook.Authors.Add(Author.Create(XXX))我可以看到我的作者指数已更新然而,该预定索引(其为母体指数)没有被更新,并寻找新添加的作者返回空结果。

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.

我不知道为什么会这样。任何人都经历了类似的困难?我倒是AP preciate它,如果我能指出了正确的方向,欢呼声。

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.

推荐答案

我最近更新了NHibernate的搜索树干来解决这个问题。您必须下载并编译最新code,然后用适当的侦听器集合变化propogate ...

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...

<listener class='NHibernate.Search.Event.FullTextIndexEventListener, NHibernate.Search' type='post-insert'/>
<listener class='NHibernate.Search.Event.FullTextIndexEventListener, NHibernate.Search' type='post-update'/>
<listener class='NHibernate.Search.Event.FullTextIndexEventListener, NHibernate.Search' type='post-delete'/>
<listener class='NHibernate.Search.Event.FullTextIndexCollectionEventListener, NHibernate.Search' type='post-collection-recreate'/>
<listener class='NHibernate.Search.Event.FullTextIndexCollectionEventListener, NHibernate.Search' type='post-collection-remove'/>
<listener class='NHibernate.Search.Event.FullTextIndexCollectionEventListener, NHibernate.Search' type='post-collection-update'/>

这篇关于当使用NHibernate.Search许多一对多的关系,处理Lucene.NET索引不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆