Nhibernate Search和Lucene.NET搜索速度很慢

时间:2011-03-11 02:05:12

标签: nhibernate lucene.net nhibernate.search

我用Lucene.NET创建了一个索引并对其进行了优化。有大约30000条记录,但是在搜索时需要大约30秒来检索任何结果!

我的配置如下:

<add key="hibernate.search.default.directory_provider" value="NHibernate.Search.Store.FSDirectoryProvider, NHibernate.Search" />
<add key="hibernate.search.default.indexBase" value="Index"/>
<add key="hibernate.search.default.exclusive_index_use" value="true" />
<add key="hibernate.search.analyzer" value="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
<add key="show_sql" value="true"/>

我的查询如下:

IFullTextSession fullTextSession = NHibernate.Search.Search.CreateFullTextSession(session);
// Build our Lucene query
StringBuilder queryString = new StringBuilder();
// Split the search string into keywords
string[] words = searchTerms.Split(" ".ToCharArray());
foreach (string keyword in words)
{
    if (!String.IsNullOrEmpty(keyword))
    {
        queryString.AppendFormat(" BusinessName:{0}", keyword);
    }
}

QueryParser parser = new QueryParser(queryString.ToString(), new StandardAnalyzer());
Query luceneQuery = parser.Parse(queryString.ToString());
// Transform the Lucene query to an NHibernate query,
// and limit the result set types to MyEntity
IQuery query = fullTextSession.CreateFullTextQuery(luceneQuery);
return query.List();

那里的任何专业人士都有任何想法,为什么会这么慢?

0 个答案:

没有答案