public bool ProcessFile(string filePath) { long ms = (long)NTFS.InfoFromPath(filePath); if (ms >= 0) { TermQuery q = new TermQuery(new Term("path", filePath)); TopDocs hits = _index_searcher.Search(q, 1); if (hits.totalHits >= 1) { Document doc = _index_searcher.Doc(hits.scoreDocs.First().doc); System.String mod = doc.Get("modified"); bool bypass = (mod == DateTools.TimeToString((long)ms, DateTools.Resolution.MINUTE)); if (!bypass) { _upd_file_list.Add(new BasicFileInfo(filePath, ms)); } } else { _add_file_list.Add(new BasicFileInfo(filePath, ms)); } } return(true); }
public void FileProcessor1(bool isStart, bool isFinished, string filePath) { if (isStart) { OpenIndex(true); return; } if (isFinished) { writer.Commit(); CloseIndex(); return; } UInt64 ms = NTFS.InfoFromPath(filePath); if (ms >= 0) { num_indexed_file++; PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new StandardAnalyzer()); analyzer.AddAnalyzer("contents", new SourceCodeAnalyzer()); analyzer.AddAnalyzer("path2", new PathAnalyzer()); //SourceCodeAnalyzer analyzer = new SourceCodeAnalyzer(); writer.AddDocument(FileDocument.Document(filePath, ms), analyzer); if (num_indexed_file % 20 == 1) { writer.Commit(); } } /* * lock (dispatch_queue) * { * if (dispatch_queue == null) * { * dispatch_queue = new Queue<string>(); * } * dispatch_queue.Enqueue(filePath); * } * */ }
public bool ProcessFile(string filePath) { long ms = (long)NTFS.InfoFromPath(filePath); if (ms >= 0) { Logger.Log.Info("Indexing " + filePath); Document doc = _doc_factory.CreateFromPath(filePath, ms); if (doc != null) { _nb_indexed++; _writer.AddDocument(doc, _default_analyzer); if (_nb_indexed % 20 == 1) { _writer.Commit(); } } } return(true); }