예제 #1
0
        private SegmentInfo IndexDoc(IndexWriter writer, System.String fileName)
        {
            System.IO.FileInfo file = new System.IO.FileInfo(System.IO.Path.Combine(workDir.FullName, fileName));
            Document           doc  = FileDocument.Document(file);

            writer.AddDocument(doc);
            writer.Flush();
            return(writer.NewestSegment());
        }
예제 #2
0
        private SegmentInfo IndexDoc(IndexWriter writer, System.String fileName)
        {
            System.IO.FileInfo file = new System.IO.FileInfo(System.IO.Path.Combine(workDir.FullName, fileName));
            Document           doc  = FileDocument.Document(file);

            doc.Add(new Field("contents", new System.IO.StreamReader(file.FullName)));
            writer.AddDocument(doc);
            writer.Commit();
            return(writer.NewestSegment());
        }
예제 #3
0
파일: TestDoc.cs 프로젝트: yonder/mono
        private void  IndexDoc(System.String segment, System.String fileName)
        {
            Directory      directory = FSDirectory.GetDirectory(indexDir, false);
            Analyzer       analyzer  = new SimpleAnalyzer();
            DocumentWriter writer    = new DocumentWriter(directory, analyzer, Similarity.GetDefault(), 1000);

            System.IO.FileInfo file = new System.IO.FileInfo(workDir.FullName + "\\" + fileName);
            Document           doc  = FileDocument.Document(file);

            writer.AddDocument(segment, doc);

            directory.Close();
        }
예제 #4
0
파일: IndexTest.cs 프로젝트: yonder/mono
 public static void  IndexDocs(IndexWriter writer, System.IO.FileInfo file)
 {
     if (System.IO.Directory.Exists(file.FullName))
     {
         System.String[] files = System.IO.Directory.GetFileSystemEntries(file.FullName);
         for (int i = 0; i < files.Length; i++)
         {
             IndexDocs(writer, new System.IO.FileInfo(file.FullName + "\\" + files[i]));
         }
     }
     else
     {
         System.Console.Out.WriteLine("adding " + file);
         writer.AddDocument(FileDocument.Document(file));
     }
 }