Exemple #1
0
        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);
        }
Exemple #2
0
        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);
             * }
             * */
        }
Exemple #3
0
        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);
        }