开发者

NHibernate.Search Index Rebuild

开发者 https://www.devze.com 2022-12-17 21:45 出处:网络
How can i rebuild Lucene.NET Index using NHibernate开发者_高级运维.Search ? Thanks.There is an Index method off of the IFullTextSearchSession that will force and index of an entity. So you just need

How can i rebuild Lucene.NET Index using NHibernate开发者_高级运维.Search ?

Thanks.


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.


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

            }
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号