好的,我已经努力尝试了2天:我想在Azure工作角色上进行全文搜索。我认为Lucene.NET很适合这个任务。我使用了这个例子:使用AzureDirectory和Lucene.NET 3.0.3.0。
我正在使用以下代码:
CloudStorageAccount cloudAccount = CloudStorageAccount.FromConfigurationSetting("CloudStorageSetting");
var cacheDirectory = new RAMDirectory();
AzureDirectory azureDirectory = new AzureDirectory(cloudAccount, "MyCloudIndex", cacheDirectory);
Analyzer analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30);
IndexWriter indexWriter = new IndexWriter(azureDirectory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
使用Lucene.Net 3.0.3.0和Lucene.Net.Store.Azure 1.0.5.1,在Azure SDK 1.8上。我也尝试了旧版Lucene.NET(2.9.xxx),但也不起作用。我更新了Windows.Azure.Storage:仍然不起作用。
问题是:Visual Studio给出了一个错误,插入到IndexWriter中的azureDirectory需要是Directory类型,而不是AzureDirectory。但是,当我将其类型更改为Directory时,它说AzureDirectory不是Directory的子类型。
为什么所有互联网上的示例都是错误的,当我字面上复制粘贴它们时却不起作用?
更新:问题已解决,我写了一篇关于此的博客文章:http://leoncullens.nl/post/2012/11/18/Full-Text-Search-on-Azure-with-LuceneNET.aspx