如题。
我已经使用eclipse调试通过。
第一次生成索引文件成功。检索成功
但是不知道windows怎么增量索引?我现在使用的是笨办法
生成索引文件在另一个文件夹,然后xcopy到我目前搜索使用的索引文件夹。
但是这样会有问题。 一旦我xcopy后,我的所搜,什么都搜不到了。
有什么好办法没有?
我已经使用eclipse调试通过。
第一次生成索引文件成功。检索成功
但是不知道windows怎么增量索引?我现在使用的是笨办法
生成索引文件在另一个文件夹,然后xcopy到我目前搜索使用的索引文件夹。
但是这样会有问题。 一旦我xcopy后,我的所搜,什么都搜不到了。
有什么好办法没有?
using Lucene.Net.Documents;
using Lucene.Net.Index;
using Lucene.Net.Store;
using Lucene.Net.Analysis.Cn;
using Lucene.Net.Analysis.CJK;
namespace SearchEnginer {
public sealed class Indexer : IDisposable {
// Directory dir = null;
IndexWriter writer = null;
private Indexer() {
}
public Indexer (string physicalPath, bool create, bool useTempDirectory) {
// if(useTempDirectory) {
// physicalPath = System.IO.Path.Combine(physicalPath, "tempindex");
// }
ChineseAnalyzer analyzer = new ChineseAnalyzer();
// dir = FSDirectory.GetDirectory(physicalPath, create);
writer = GetWriter(physicalPath);//new IndexWriter(dir, analyzer, create);
writer.mergeFactor = 15;
}
public void AddDocument (Document doc) {
writer.AddDocument(doc);
}
private IndexWriter GetWriter(string physicalPath) {
IndexWriter indexWriter = null;
string segmentFile = System.IO.Path.Combine(physicalPath, "segments");
if ( System.IO.File.Exists(segmentFile) )
indexWriter = new IndexWriter(physicalPath, new Lucene.Net.Analysis.Cn.ChineseAnalyzer(), false);
else
indexWriter = new IndexWriter(physicalPath, new Lucene.Net.Analysis.Cn.ChineseAnalyzer(), true);
return indexWriter;
}
public void Close() {
if (!disposed) {
// dir.Close();
writer.Optimize();
writer.Close();
disposed = true;
}
}
private bool disposed = false;
public void Dispose() {
Close();
}
}
}