///////////////////////////////////////////////////////// // Execute a lucene optimize-task on the index. static void ExecuteOptimize(string index_dir) { LuceneIndexingDriver driver = new LuceneIndexingDriver(index_dir, false); Stopwatch watch = new Stopwatch(); watch.Start(); driver.OptimizeNow(); watch.Stop(); Console.WriteLine("Optimized index {0} in {1}", driver.TopDirectory, watch); }
///////////////////////////////////////////////////////// // Execute a lucene optimize-task on the index. static void ExecuteOptimize(string index_dir) { LuceneIndexingDriver driver = new LuceneIndexingDriver(index_dir, false); // Set system priorities so we don't slow down the system SystemPriorities.ReduceIoPriority(); SystemPriorities.SetSchedulerPolicyBatch(); Stopwatch watch = new Stopwatch(); watch.Start(); driver.OptimizeNow(); watch.Stop(); Console.WriteLine("Optimized index {0} in {1}", driver.TopDirectory, watch); }
static void DoIndexing() { int count_dirs = 0; int count_files = 0; Indexable indexable; pending_request = new IndexerRequest(); Queue modified_directories = new Queue(); while (pending_directories.Count > 0) { DirectoryInfo dir = (DirectoryInfo)pending_directories.Dequeue(); AddToRequest(DirectoryToIndexable(dir, modified_directories)); try { if (arg_recursive) { foreach (DirectoryInfo subdir in DirectoryWalker.GetDirectoryInfos(dir)) { if (!Ignore(subdir) && !FileSystem.IsSpecialFile(subdir.FullName)) { pending_directories.Enqueue(subdir); } } } foreach (FileInfo file in DirectoryWalker.GetFileInfos(dir)) { if (!Ignore(file)) { AddToRequest(FileToIndexable(file)); count_files++; } } } catch (DirectoryNotFoundException) {} if (Shutdown.ShutdownRequested) { break; } count_dirs++; } Logger.Log.Debug("Scanned {0} files and directories in {1} directories", count_dirs + count_files, count_dirs); if (Shutdown.ShutdownRequested) { backing_fa_store.Flush(); return; } // Time to remove deleted directories from the index and attributes store while (modified_directories.Count > 0) { DirectoryInfo subdir = (DirectoryInfo)modified_directories.Dequeue(); Logger.Log.Debug("Checking {0} for deleted files and directories", subdir.FullName); // Get a list of all documents from lucene index with ParentDirUriPropKey set as that of subdir ICollection all_dirent = GetAllItemsInDirectory(subdir); foreach (Dirent info in all_dirent) { // check if the item exists if ((!info.IsDirectory && File.Exists(info.FullName)) || (info.IsDirectory && Directory.Exists(info.FullName))) { continue; } if (info.IsDirectory) { // Recursively remove deleted subdirectories modified_directories.Enqueue(new DirectoryInfo(info.FullName)); } // remove Uri uri = PathToUri(info.FullName); indexable = new Indexable(IndexableType.Remove, uri); AddToRequest(indexable); } } bool reschedule = false; // Call Flush until our request is empty. We have to do this in a loop // because Flush happens in a batch size and some indexables might generate more indexables while (reschedule || pending_request.Count > 0) { if (Shutdown.ShutdownRequested) { break; } reschedule = FlushIndexer(driver); } backing_fa_store.Flush(); if (Shutdown.ShutdownRequested) { return; } Logger.Log.Debug("Optimizing index"); driver.OptimizeNow(); }
///////////////////////////////////////////////////////// // Execute a lucene optimize-task on the index. static void ExecuteOptimize(string index_dir) { LuceneIndexingDriver driver = new LuceneIndexingDriver (index_dir, false); // Set system priorities so we don't slow down the system SystemPriorities.ReduceIoPriority (); SystemPriorities.SetSchedulerPolicyBatch (); Stopwatch watch = new Stopwatch (); watch.Start (); driver.OptimizeNow (); watch.Stop (); Console.WriteLine ("Optimized index {0} in {1}", driver.TopDirectory, watch); }
///////////////////////////////////////////////////////// // Execute a lucene optimize-task on the index. static void ExecuteOptimize (string index_dir) { LuceneIndexingDriver driver = new LuceneIndexingDriver (index_dir, false); Stopwatch watch = new Stopwatch (); watch.Start (); driver.OptimizeNow (); watch.Stop (); Console.WriteLine ("Optimized index {0} in {1}", driver.TopDirectory, watch); }