1
我想創建一個IndexWriter並寫入一個Lucene索引。這裏是我的代碼:Lucene IndexWriter已經設置異常
public class Indexer {
public static Analyzer _analyzer = new StandardAnalyzer(Lucene.Net.Util.LuceneVersion.LUCENE_48);
private void WriteToIndex() {
var config = new IndexWriterConfig(Lucene.Net.Util.LuceneVersion.LUCENE_48, _analyzer).SetUseCompoundFile(false);
using (IndexWriter indexWriter = new IndexWriter(LuceneDirectory, config)) <-- This throws an error!
{
// ....
}
}
}
但我不斷收到試圖創建的IndexWriter時異常:
Exception thrown: 'Lucene.Net.Util.SetOnce`1.AlreadySetException' in Lucene.Net.dll
Additional information: The object cannot be set twice!
我在做什麼錯?代碼完美編譯。我正在使用Lucene.NET,但我猜它也應該適用於Java。