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()); }
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()); }
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(); }
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)); } }