Reputation: 12476
Alright, I've been trying to get this working for 2 days: I want to full text search on an Azure worker role. I think Lucene.NET is good for this. I've used this example: Use AzureDirectory with Lucene.NET 3.0.3.0.
I'm using the code below:
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);
With Lucene.Net 3.0.3.0 and Lucene.Net.Store.Azure 1.0.5.1, on Azure SDK 1.8. I also tried the older Lucene.NET (2.9.xxx) but that didn't work either. I updated Windows.Azure.Storage: still doesn't work.
The problem is: Visual Studio gives me an error that the azureDirectory
that is inserted into IndexWriter
needs to be of type Directory
instead of AzureDirectory
. When I change its type to Directory
however, it says that AzureDirectory
is not a subtype of Directory
.
How come ALL the examples on the internet are wrong and don't work when I literally copy paste them?
Update: the issue is fixed, I wrote a blog post about it: http://leoncullens.nl/post/2012/11/18/Full-Text-Search-on-Azure-with-LuceneNET.aspx
Upvotes: 3
Views: 1903
Reputation: 2353
I have 'forked' this project, updated the Lucene reference to 3.0.3, and updated the Azure Storage client to 2.0 (the version that ships with v1.8 SDK), and placed the code here:
https://github.com/richorama/AzureDirectory
It should be relatively straight forward to copy the sample code in the 'TestApp' to figure out how to use this version of Lucene.NET.
*disclaimer, I am not a Lucene expert, and I haven't tested this properly - use at your own risk!
Upvotes: 2
Reputation: 1749
A couple of months ago this setup worked for me for LUCENE version 2.9 and an older Azure SDK. The main difference between working and non-working was to NOT using RAMDirectory since eventually it ran out of RAM. After NOT using RAMDirectory, I was successful in indexing 25 GB of data.
_azureDirectory = new AzureDirectory
( storageAccount
, catalogName
//, new RAMDirectory());
_version = Lucene.Net.Util.Version.LUCENE_29;
_analyzer = new StandardAnalyzer(_version);
IndexWriter
writer = new IndexWriter(
_azureDirectory,
_analyzer,
newIndex, // new index or update
IndexWriter.MaxFieldLength.UNLIMITED);
writer.SetUseCompoundFile(false);
writer.SetRAMBufferSizeMB(800);
writer.SetMergeFactor(10);
Upvotes: 0
Reputation: 3683
Its not going work...Here is my answer on why its not and what you can do: How to implement Lucene .Net search on Azure webrole
Here is another answer that might help, but I don't agree with the approach: https://azuredirectory.codeplex.com/discussions/402913
Edit: I should clarify that when I say "work" I mean work in a production environment.
Upvotes: 0