lucene.net 全文检索的问题

xue119 2011-05-19 10:39:20
1. 建立索引到下面各个目录

A 目录 (1.39GB)
B 目录 (70.8MB)
C 目录 (10.2MB)
D 目录 (325MB)
E 目录 (7.21MB)
F 目录 (21.3MB)

2. 搜索单个目录时 耗时 2~4 秒之间

代码如下
System.IO.DirectoryInfo[] DirInfos = new DirectoryInfo[6];
Lucene.Net.Search.IndexSearcher []Searcher = new IndexSearcher[6];
String key = String.Empty;

DirInfos[0] = new DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings["A"]);
DirInfos[1] = new DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings["B"]);
DirInfos[2] = new DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings["C"]);
DirInfos[3] = new DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings["C"]);
DirInfos[4] = new DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings["E"]);
DirInfos[5] = new DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings["F"]);



Lucene.Net.Store.Directory IndexDir = Lucene.Net.Store.FSDirectory.Open(DirInfos[0]);
Searcher[0] = new IndexSearcher(IndexDir, true);

IndexDir = Lucene.Net.Store.FSDirectory.Open(DirInfos[1]);
Searcher[1] = new IndexSearcher(IndexDir, true);

IndexDir = Lucene.Net.Store.FSDirectory.Open(DirInfos[2]);
Searcher[2] = new IndexSearcher(IndexDir, true);

IndexDir = Lucene.Net.Store.FSDirectory.Open(DirInfos[3]);
Searcher[3] = new IndexSearcher(IndexDir, true);

IndexDir = Lucene.Net.Store.FSDirectory.Open(DirInfos[4]);
Searcher[4] = new IndexSearcher(IndexDir, true);

IndexDir = Lucene.Net.Store.FSDirectory.Open(DirInfos[5]);
Searcher[5] = new IndexSearcher(IndexDir, true);


MultiSearcher ms = new MultiSearcher(Searcher);

Analyzer WordBreaker = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29);

//Sort sort = new Sort(new SortField("PublishDate", SortField.DOC, false));

String[] keywords={"中国","中国","中国"};
String[] fields ={"Title","Summary","Content"};
BooleanClause.Occur[] clause ={BooleanClause.Occur.SHOULD,BooleanClause.Occur.SHOULD,BooleanClause.Occur.SHOULD};
Query QueryResult = MultiFieldQueryParser.Parse(Lucene.Net.Util.Version.LUCENE_29, keywords, fields, clause, WordBreaker);

DateTime now = DateTime.Now;

//得到ScoreDoc数组
sc = ms.Search(QueryResult, 9999999).scoreDocs;


这段代码耗时达 18~ 25 秒之间

问一下,大家有没有什么办法能提高搜索效率? 急~~~~~~

...全文
161 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

25,983

社区成员

发帖
与我相关
我的任务
社区描述
高性能WEB开发
社区管理员
  • 高性能WEB开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧