title: How can I improve Lucene.net indexing speed
body: <p>I am using lucene.net to index my pdf files. It takes about <strong>40 minutes to index 15000 pdfs</strong> and indexing time increase with number of pdf file increase in my folder. </p>
  
  <ul>
  <li><strong>how can I improve indexing speed in lucene.net?</strong></li>
  <li><strong>Is there any other indexing service with fast indexing performance?</strong></li>
  </ul>
  
  <p>I am using latest version of lucene.net indexing (Lucene.net 3.0.3).</p>
  
  <p>Here is my code for indexing. </p>
  
  <pre><code>public void refreshIndexes() 
          {
              // Create Index Writer
              string strIndexDir = @"E:\LuceneTest\index";
              IndexWriter writer = new IndexWriter(Lucene.Net.Store.FSDirectory.Open(new System.IO.DirectoryInfo(strIndexDir)), new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29), true, IndexWriter.MaxFieldLength.UNLIMITED);
  
              // Find all files in root folder create index on them
              List&lt;string&gt; lstFiles = searchFiles(@"E:\LuceneTest\PDFs");
              foreach (string strFile in lstFiles)
              {
                  Document doc = new Document();
                  string FileName = System.IO.Path.GetFileNameWithoutExtension(strFile);
                  string Text = ExtractTextFromPdf(strFile);
                  string Path = strFile;
                  string ModifiedDate = Convert.ToString(File.GetLastWriteTime(strFile));
                  string DocumentType = string.Empty;
                  string Vault = string.Empty;
  
                  string headerText = Text.Substring(0, Text.Length &lt; 150 ? Text.Length : 150);
                  foreach (var docs in ltDocumentTypes)
                  {
                      if (headerText.ToUpper().Contains(docs.searchText.ToUpper()))
                      {
                          DocumentType = docs.DocumentType;
                          Vault = docs.VaultName; ;
                      }
                  }
  
                  if (string.IsNullOrEmpty(DocumentType))
                  {
                      DocumentType = "Default";
                      Vault = "Default";
                  }
  
                  doc.Add(new Field("filename", FileName, Field.Store.YES, Field.Index.ANALYZED));
                  doc.Add(new Field("text", Text, Field.Store.YES, Field.Index.ANALYZED));
                  doc.Add(new Field("path", Path, Field.Store.YES, Field.Index.NOT_ANALYZED));
                  doc.Add(new Field("modifieddate", ModifiedDate, Field.Store.YES, Field.Index.ANALYZED));
                  doc.Add(new Field("documenttype", DocumentType, Field.Store.YES, Field.Index.ANALYZED));
                  doc.Add(new Field("vault", Vault, Field.Store.YES, Field.Index.ANALYZED));
  
                  writer.AddDocument(doc);
              }
              writer.Optimize();
              writer.Dispose();
          }
  </code></pre>