我需要圍繞10GB的數據指標。我的每個「文檔」都非常小,想想關於產品的基本信息,大約20個字段的數據,大多數只有幾個字。只有1列被索引,其餘的被存儲。我從文本文件中獲取數據,因此部分速度非常快。如何優化Lucene.Net索引
當前索引速度只有大約每小時40MB。我聽說其他人說他們已經比這快100倍了。對於較小的文件(大約20mb),索引速度非常快(5分鐘)。然而,當我有了它的時候,我可以遍歷所有的數據文件(大約50個文件總計10GB),隨着時間的推移,指數的增長似乎減慢了很多。關於如何加快索引速度或者最佳索引速度的想法?
在一個側面說明,我注意到在.NET端口API似乎並沒有包含所有的相同的方法,Java的原...
更新 - 這裏的片段索引C#代碼: 首先,我設置的事情:
using (System.IO.TextReader tr = System.IO.File.OpenText(File))
{
string line;
while ((line = tr.ReadLine()) != null)
{
string[] items = line.Split('\t');
然後創建字段和文檔添加到:
directory = FSDirectory.GetDirectory(@txtIndexFolder.Text, true);
iwriter = new IndexWriter(directory, analyzer, true);
iwriter.SetMaxFieldLength(25000);
iwriter.SetMergeFactor(1000);
iwriter.SetMaxBufferedDocs(Convert.ToInt16(txtBuffer.Text));
然後從製表DELIM數據文件讀取指數:
fldName = new Field("Name", items[4], Field.Store.YES, Field.Index.NO);
doc.Add(fldName);
fldUPC = new Field("UPC", items[10], Field.Store.YES, Field.Index.NO);
doc.Add(fldUPC);
string Contents = items[4] + " " + items[5] + " " + items[9] + " " + items[10] + " " + items[11] + " " + items[23] + " " + items[24];
fldContents = new Field("Contents", Contents, Field.Store.NO, Field.Index.TOKENIZED);
doc.Add(fldContents);
...
iwriter.AddDocument(doc);
一旦它完全做到了索引:
iwriter.Optimize();
iwriter.Close();
您能否詳細說明(a)文件總數(b)使用的分析儀(c)索引字段的長度?也只是爲了確認,你是否重新使用IndexWriter? – 2010-10-08 07:43:56
文件總數約爲10,000,000。 StandardAnalyzer。是的,我正在重新使用IndexWriter和Document,但無法重新使用Field,因爲C#端口似乎沒有實現Field.SetValue。 – alchemical 2010-10-08 15:33:53
我實際上只是將它加載到專用服務器上,並且SetMaxBufferDocs爲25000.它在開始時速度非常快......但在8小時後,索引僅爲150MB左右。 – alchemical 2010-10-08 15:36:07