سؤال

كنت تواجه صعوبة في الحصول على nHibernate.البحث إنشاء فهرس.

إذا كنت تستخدم 1.2.1.4 من nHibernate.dll & nHibernate.Search.dll ثم مؤشر يتم إنشاؤه بشكل صحيح وأنا يمكن أن تفقد مع لوقا (أ لوسين المنفعة).على شرائح يتم إنشاء ملف فضلا عن شظايا ملف الخ

ومع ذلك ، عندما استخدم v 2 nHibernate.dll & nHibernate.Search.dll ثم مؤشر لا يتم إنشاء بشكل صحيح.فقط 1 كيلو شرائح يتم إنشاء ملف في مؤشر دليل لوقا هو قادر على تفتيشها.

رمز اعتدت في v1 كانت على النحو التالي:

_configuration = new Configuration();
_configuration.Configure();
_configuration.AddAssembly(typeof (Contact).Assembly);
_sessionFactory = _configuration.BuildSessionFactory();
SearchFactory.Initialize(_configuration, _sessionFactory);

وأنا التالية في ملف التكوين

<property name="hibernate.search.default.directory_provider">NHibernate.Search.Storage.FSDirectoryProvider, NHibernate.Search</property>
<property name="hibernate.search.default.indexBase">~/Index</property>

في الإصدار 2 لا يوجد SearchFactory.فقط شيء مماثل لا يمكن أن تجد

SearchFactoryImpl.GetSearchFactory(_configuration);

لذلك يجب إعداد التكوين على النحو التالي

_configuration = new Configuration();
_configuration.Configure();
_configuration.AddAssembly(typeof (Contact).Assembly);
_sessionFactory = _configuration.BuildSessionFactory();
_configuration.SetProperty("hibernate.search.default.directory_provider",
                                       "NHibernate.Search.Store.FSDirectoryProvider, NHibernate.Search");

_configuration.SetProperty("hibernate.search.default.indexBase", "Index");
_configuration.SetProperty("hibernate.search.analyzer",
                                        "Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net");


_configuration.SetListener(ListenerType.PostUpdate, new FullTextIndexEventListener());
_configuration.SetListener(ListenerType.PostInsert, new FullTextIndexEventListener());
_configuration.SetListener(ListenerType.PostDelete, new FullTextIndexEventListener());

SearchFactoryImpl.GetSearchFactory(_configuration);

وهذا يخلق العظام العارية من فهرس ولكنها ليست للعرض مع لوقا - الذي يحكي لي هو الفاسدة

كما تستخدم التعليمة البرمجية التالية في محاولة لخلق المؤشر يدويا ، ولكن مرة أخرى أنه الوحيد يخلق قطاعات ملف شيء آخر

public void CreateIndex<T>(string rootIndexDirectory)
{
    Type type = typeof (T);

    var info = new DirectoryInfo(Path.Combine(rootIndexDirectory, type.Name));

    // Recursively delete the index and files in there
    if (info.Exists) info.Delete(true);

    // Now recreate the index
    FSDirectory dir = FSDirectory.GetDirectory(Path.Combine(rootIndexDirectory, type.Name), true);
    //Ioc.UrlProvider.MapPath(Path.Combine(rootIndexDirectory, type.Name)), true);

    try
    {
        var writer = new IndexWriter(dir, new StandardAnalyzer(), true);
        writer.Close();
    }
    finally
    {
        if (dir != null) 
            dir.Close();
    }

    using (ISession session = _sessionFactory.OpenSession())
    {
        using (IFullTextSession fullTextSession = Search.CreateFullTextSession(session)) 
        {
            foreach (var contact in _contacts)
            {
                //session.Save(contact);
                fullTextSession.Index(contact);
            }
        }
    }
}

لذا سؤالي هو هل يجب علي استخدام v1.1.4 من nHibernate إذا كنت ترغب في استخدام nHibernate.البحث ؟ أو هل يمكنني استخدام v2 ؟ في هذه الحالة ماذا أفعل الخطأ ؟

هناك القليل جدا على شبكة الإنترنت حول هذا الموضوع.

أي شخص ؟

هل كانت مفيدة؟

المحلول

لقد وجدت على سبيل المثال العمل هنا:

http://darioquintana.com.ar/blogging/?p=21

V2 nHibernate.Search.dll في هذا المشروع لا تحتوي على SearchFactory (وإن كان في الاسم).

واحد جمعت من SVN مستودع لا يكون هذا

لذلك كل مرتبة

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top