Lucene.Net + カスタム クローラー + Ifilter を使用して、ブロブ内のデータをインデックス化できるようにしています。
foreach (var item in containerList)
{
CloudBlobContainer container = BlobClient.GetContainerReference(item.Name);
if (container.Name != "indexes")
{
IEnumerable<IListBlobItem> blobs = container.ListBlobs();
foreach (CloudBlob blob in blobs)
{
CloudBlobContainer blobContainer = blob.Container;
CloudBlob blobToDownload = blobContainer.GetBlobReference(blob.Name);
blob.DownloadToFile(path+blob.Name);
indexer.IndexBlobData(path,blob);
System.IO.File.Delete(path+blob.Name);
}
}
}
/*Code for crawling which downloads file Locally on azure instance storage*/
以下のコードは、IFilter を使用するインデクサー関数です。
public bool IndexBlobData(string path, CloudBlob blob)
{
Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
try
{
TextReader reader = new FilterReader(path + blob.Name);
doc.Add(new Lucene.Net.Documents.Field("url", blob.Uri.ToString(), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NOT_ANALYZED));
doc.Add(new Lucene.Net.Documents.Field("content", reader.ReadToEnd().ToString(), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.ANALYZED));
indexWriter.AddDocument(doc);
reader.Close();
return true;
}
catch (Exception e)
{
return false;
}
}
今私の問題は、インスタンスストレージにファイルをダウンロードしたくないということです..ファイルを直接FilterReaderに渡したいです。ただし、「物理」パスを使用するため、http アドレスを渡すことはできません。誰かが他の回避策を提案できますか? 同じファイルを BLOB から再度ダウンロードしてインデックスを作成するのではなく、ダウンロードしてメイン メモリに保持し、インデックス フィルターを直接使用します。
ここからIFilterを使用しています