2011-09-09 3 views
0

私はWebクローラーをやっています。ストリーミングが進行中または完了している間、インデックス作成にluceneを使用したいと思います。Lucene.net HTMLファイルの代わりにhtmlの文字列を含むドキュメントの例ですか?

私はlucene.net htmlライブラリの例が良いことを見てきました。しかし、私はディスクにダウンロードし続けたくありません。私は何を望んでいて、ウェブをダウンロードしている間、または多分HTMLコンテンツの文字列のインデックスをダウンロード中にインデックスを作成しているだけです。

lucence.net htmlインデクサがメモリストリームまたは文字列を処理する例はありますか?

答えて

0

何か?

 // create writer to index 
     IndexWriter iw = new IndexWriter(new FileInfo("C:\\example\\"), new StandardAnalyzer()); 

     // create a document to index 
     Document d = new Document(); 

     // create a field that the document will contain 
     Field aField = new Field("test", "", Field.Store.YES, Field.Index.ANALYZED); 
     // add the field to the document 
     d.Add(aField); 

     // index some data (4 documents) 
     aField.SetValue("Example 1"); 
     iw.AddDocument(d); 
     aField.SetValue("Example 2"); 
     iw.AddDocument(d); 
     aField.SetValue("Example 3"); 
     iw.AddDocument(d); 

     aField.SetValue("Example 4"); 
     // a field with Store.NO can be set with a TextReader 
     Field notStored = new Field("test2", "", Field.Store.NO, Field.Index.ANALYZED); 
     notStored.SetValue(new StringReader("Example 4 - From TextReader")); 
     // add new field to a 4th document 
     d.Add(notStored); 
     iw.AddDocument(d); 

     // closing writer commits changes to disk 
     iw.Close(); 
関連する問題