NHibernate.Search Index Rebuild

柔情痞子 提交于 2019-12-11 03:09:56

问题


How can i rebuild Lucene.NET Index using NHibernate.Search ?

Thanks.


回答1:


There is an Index method off of the IFullTextSearchSession that will force and index of an entity. So you just need to retrieve all of the objects and then call index on them.




回答2:


Here is an example:

    public void Index(List<object> entities, ISession s)
    {
        using (var search = NHibernate.Search.Search.CreateFullTextSession(s))
        {
            foreach (var entity in entities)
            {
                using (var tx = s.BeginTransaction())
                {
                    search.Index(entity);
                    tx.Commit();
                }

            }
        }


来源:https://stackoverflow.com/questions/2111117/nhibernate-search-index-rebuild

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!